This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f2812
commit 4d61fc5
Showing
6 changed files
with
147 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
Metadata-Version: 1.1 | ||
Name: huaweicloud-sdk-python | ||
Version: 1.0.23 | ||
Version: 1.0.24 | ||
Summary: An SDK for building applications to work with OpenStack | ||
Home-page: https://github.com/huaweicloud/huaweicloud-sdk-python | ||
Author: huawei | ||
Author-email: | ||
License: UNKNOWN | ||
Author: "HuaweiCloud SDK" | ||
Author-email: "[email protected]" | ||
License: Apache LICENSE 2.0 | ||
Description: Python SDK for Cloud | ||
|
||
Platform: UNKNOWN | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from openstack import connection | ||
|
||
|
||
projectId = "xxxxxxxxxxxxxx" | ||
cloud = "xxxxxxxxxxxxxx" # cdn use: cloud = "myhwclouds.com" | ||
region = "xxxxxxxxxxxxxx" # example: region = "cn-north-1" | ||
AK = "xxxxxxxxxxxxxx" | ||
SK = "xxxxxxxxxxxxxx" | ||
connect = connection.Connection( | ||
project_id=projectId, | ||
cloud=cloud, | ||
region=region, | ||
ak=AK, | ||
sk=SK) | ||
|
||
|
||
def databases(conn): | ||
instance_id = 'xxxxxxxxxxxxxxxxxxxxxxx' | ||
query = { | ||
'page': 1, | ||
'limit': 10 | ||
} | ||
for database in conn.rdsv3.databases(instance_id, details=True, **query): | ||
print(database) | ||
|
||
|
||
def create_database(conn): | ||
database = { | ||
"name": 'test_db1', | ||
"character_set": 'utf8' | ||
} | ||
instance_id = 'xxxxxxxxxxxxxxxxxxxxxxx' | ||
print(conn.rdsv3.create_database(instance_id=instance_id, **database)) | ||
|
||
|
||
def delete_database(conn): | ||
database_name = 'test_db1' | ||
instance_id = 'xxxxxxxxxxxxxxxxxxxxxxx' | ||
print(conn.rdsv3.delete_database(database_name, instance_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding:utf-8 -*- | ||
# Copyright 2019 Huawei Technologies Co.,Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
# this file except in compliance with the License. You may obtain a copy of the | ||
# License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
from openstack.rds import rds_service | ||
from openstack.rds.v3 import rdsresource as _rdsresource | ||
from openstack import resource2 as resource | ||
|
||
|
||
class Database(_rdsresource.Resource): | ||
base_path = 'instances/%(instance_id)s/database' | ||
resources_key = 'databases' | ||
service = rds_service.RDSServiceV3() | ||
|
||
_query_mapping = resource.QueryParameters('page', 'limit') | ||
|
||
# capabilities | ||
allow_create = True | ||
allow_delete = True | ||
allow_list = True | ||
|
||
# Properties | ||
# instanceId | ||
instance_id = resource.URI('instance_id') | ||
# database name | ||
name = resource.Body("name") | ||
# database character_set | ||
character_set = resource.Body("character_set") | ||
|
||
|
||
class DatabaseDetail(Database): | ||
base_path = 'instances/%(instance_id)s/database/detail' | ||
|
||
# capabilities | ||
allow_create = False | ||
allow_delete = False | ||
allow_list = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters