當前位置: 首頁>>代碼示例>>Python>>正文


Python ProfitBricksService.list_locations方法代碼示例

本文整理匯總了Python中profitbricks.client.ProfitBricksService.list_locations方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfitBricksService.list_locations方法的具體用法?Python ProfitBricksService.list_locations怎麽用?Python ProfitBricksService.list_locations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在profitbricks.client.ProfitBricksService的用法示例。


在下文中一共展示了ProfitBricksService.list_locations方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestLocation

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import list_locations [as 別名]
class TestLocation(unittest.TestCase):
    def setUp(self):
        self.location = ProfitBricksService(
            username='username', password='password')

    def test_list_locations(self):
        locations = self.location.list_locations()

        self.assertEqual(len(locations), 4)
        self.assertEqual(locations['items'][0]['id'], 'de/fra')
        self.assertEqual(
            locations['items'][0]['properties']['name'], 'Europe / Germany / Frankfurt')

    def test_get_location(self):
        location = self.location.get_location(location_id)

        self.assertEqual(location['id'], 'de/fra')
        self.assertEqual(
            location['properties']['name'], 'Europe / Germany / Frankfurt')
開發者ID:grandvizier,項目名稱:profitbricks-sdk-python,代碼行數:21,代碼來源:test_location.py

示例2: TestLocation

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import list_locations [as 別名]
class TestLocation(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.resource = resource()
        self.client = ProfitBricksService(
            username=configuration.USERNAME, password=configuration.PASSWORD, headers=configuration.HEADERS
        )

    def test_list_locations(self):
        locations = self.client.list_locations()

        self.assertEqual(len(locations), 4)
        for location in locations["items"]:
            self.assertEqual(location["type"], "location")
            self.assertIn(location["id"], self.resource["locations"])

    def test_get_location(self):
        location = self.client.get_location(configuration.LOCATION)

        self.assertEqual(location["type"], "location")
        self.assertEqual(location["id"], configuration.LOCATION)
開發者ID:fbrehm,項目名稱:profitbricks-sdk-python,代碼行數:23,代碼來源:test_location_live.py

示例3: main

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import list_locations [as 別名]
def main(argv=None):
    '''parse command line and write file.'''

    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    program_name = os.path.basename(sys.argv[0])
    program_version = "v%s" % __version__
    program_build_date = str(__updated__)
    program_version_message = '%%(prog)s %s (%s)' % (program_version,
                                                     program_build_date)
    program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
    program_license = '''%s

  Created by J. Buchhammer on %s.
  Copyright 2016 ProfitBricks GmbH. All rights reserved.

  Licensed under the Apache License 2.0
  http://www.apache.org/licenses/LICENSE-2.0

  Distributed on an "AS IS" basis without warranties
  or conditions of any kind, either express or implied.

USAGE
''' % (program_shortdesc, str(__date__))

    try:
        # Setup argument parser
        parser = ArgumentParser(description=program_license,
                                formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument('-u', '--user', dest='user', 
                            required=True, help='the login name')
        parser.add_argument('-p', '--password', dest='password',
                            required=True, help='the login password')
        parser.add_argument('-L', '--Login', dest='loginfile', default=None,
                            required=True, help='the login file to use')
        parser.add_argument('-v', '--verbose', dest="verbose", action="count",
                            help="set verbosity level [default: %(default)s]")
        parser.add_argument('-V', '--version', action='version',
                            version=program_version_message)

        # Process arguments
        args = parser.parse_args()
        global verbose
        verbose = args.verbose

        if verbose > 0:
            print("Verbose mode on")

        (user, password) = getLogin(args.loginfile, args.user, args.password)
        if user is None or password is None:
            raise ValueError("user or password resolved to None")
        print("testing access..")
        pbclient = ProfitBricksService(user, password)
        pbclient.list_locations()

    except KeyboardInterrupt:
        # handle keyboard interrupt #
        return 0
    except Exception:
        traceback.print_exc()
        sys.stderr.write("\n" + program_name + ":  for help use --help\n")
        return 2
開發者ID:linearregression,項目名稱:bright-cluster-scaling-profitbricks,代碼行數:67,代碼來源:pb_saveLoginFile.py


注:本文中的profitbricks.client.ProfitBricksService.list_locations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。