Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update api from api specs #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/qingcloud/sdk/service/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def describe_image_users(image_id: "", limit: nil, offset: nil)
end

# Documentation URL: https://docs.qingcloud.com/api/image/describe_images.html
def describe_images(images: [], limit: nil, offset: nil, os_family: "", owner: "", processor_type: "", project_id: "", provider: "", search_word: "", status: [], verbose: nil, visibility: "")
def describe_images(images: [], limit: nil, offset: nil, os_family: "", owner: "", processor_type: "", project_id: "", provider: "", search_word: "", status: [], tags: [], verbose: nil, visibility: "")
input = {
config: config,
properties: properties,
Expand All @@ -101,6 +101,7 @@ def describe_images(images: [], limit: nil, offset: nil, os_family: "", owner: "
"provider" => provider, # provider's available values: system, self
"search_word" => search_word,
"status" => status,
"tags" => tags,
"verbose" => verbose, # verbose's available values: 0
"visibility" => visibility, # visibility's available values: public, private
},
Expand Down
29 changes: 27 additions & 2 deletions lib/qingcloud/sdk/service/load_balancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ def associate_eips_to_load_balancer(eips: [], loadbalancer: "")
end

# Documentation URL: https://docs.qingcloud.com/api/lb/create_loadbalancer.html
def create_load_balancer(eips: [], http_header_size: nil, loadbalancer_name: "", loadbalancer_type: nil, node_count: nil, private_ip: "", project_id: "", security_group: "", vxnet: "")
def create_load_balancer(cluster_mode: nil, eips: [], http_header_size: nil, loadbalancer_name: "", loadbalancer_type: nil, mode: nil, node_count: nil, private_ip: "", project_id: "", security_group: "", vxnet: "")
input = {
config: config,
properties: properties,
api_name: "CreateLoadBalancer",
request_method: "GET",
request_params: {
"cluster_mode" => cluster_mode, # cluster_mode's available values: 0, 1
"eips" => eips,
"http_header_size" => http_header_size,
"loadbalancer_name" => loadbalancer_name,
"loadbalancer_type" => loadbalancer_type, # loadbalancer_type's available values: 0, 1, 2, 3, 4, 5
"mode" => mode, # mode's available values: 0, 1
"node_count" => node_count,
"private_ip" => private_ip,
"project_id" => project_id,
Expand Down Expand Up @@ -522,7 +524,7 @@ def modify_load_balancer_backend_attributes(disabled: nil, loadbalancer_backend:
end

# Documentation URL: https://docs.qingcloud.com/api/lb/modify_loadbalancer_listener_attributes.html
def modify_load_balancer_listener_attributes(balance_mode: "", forwardfor: nil, healthy_check_method: "", healthy_check_option: "", listener_option: nil, loadbalancer_listener: "", loadbalancer_listener_name: "", server_certificate_id: [], session_sticky: "", timeout: nil)
def modify_load_balancer_listener_attributes(balance_mode: "", forwardfor: nil, healthy_check_method: "", healthy_check_option: "", listener_option: nil, loadbalancer_listener: "", loadbalancer_listener_name: "", scene: nil, server_certificate_id: [], session_sticky: "", timeout: nil)
input = {
config: config,
properties: properties,
Expand All @@ -536,6 +538,7 @@ def modify_load_balancer_listener_attributes(balance_mode: "", forwardfor: nil,
"listener_option" => listener_option,
"loadbalancer_listener" => loadbalancer_listener,
"loadbalancer_listener_name" => loadbalancer_listener_name,
"scene" => scene,
"server_certificate_id" => server_certificate_id,
"session_sticky" => session_sticky,
"timeout" => timeout,
Expand Down Expand Up @@ -745,6 +748,17 @@ def associate_eips_to_load_balancer_input_validate(input)
def create_load_balancer_input_validate(input)
input.deep_stringify_keys!

unless input["request_params"]["cluster_mode"].to_s.empty?
cluster_mode_valid_values = ["0", "1"]
unless cluster_mode_valid_values.include? input["request_params"]["cluster_mode"].to_s
raise ParameterValueNotAllowedError.new(
"cluster_mode",
input["request_params"]["cluster_mode"],
cluster_mode_valid_values
)
end
end

unless input["request_params"]["loadbalancer_type"].to_s.empty?
loadbalancer_type_valid_values = ["0", "1", "2", "3", "4", "5"]
unless loadbalancer_type_valid_values.include? input["request_params"]["loadbalancer_type"].to_s
Expand All @@ -755,6 +769,17 @@ def create_load_balancer_input_validate(input)
)
end
end

unless input["request_params"]["mode"].to_s.empty?
mode_valid_values = ["0", "1"]
unless mode_valid_values.include? input["request_params"]["mode"].to_s
raise ParameterValueNotAllowedError.new(
"mode",
input["request_params"]["mode"],
mode_valid_values
)
end
end
end

def create_load_balancer_policy_input_validate(input)
Expand Down
27 changes: 27 additions & 0 deletions lib/qingcloud/sdk/service/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ def get_quota_left(resource_types: [], zone: "")
request.send
end

# Documentation URL: https://docs.qingcloud.com/product/api/action/misc
def get_resource_limit(volume_type: nil, zone: "")
input = {
config: config,
properties: properties,
api_name: "GetResourceLimit",
request_method: "GET",
request_params: {
"volume_type" => volume_type,
"zone" => zone,
},
}

get_resource_limit_input_validate input

request = Request.new input
request.send
end

private

def get_quota_left_input_validate(input)
Expand All @@ -54,6 +73,14 @@ def get_quota_left_input_validate(input)
raise ParameterRequiredError.new("zone", "GetQuotaLeftInput")
end
end

def get_resource_limit_input_validate(input)
input.deep_stringify_keys!

if input["request_params"]["zone"].to_s.empty?
raise ParameterRequiredError.new("zone", "GetResourceLimitInput")
end
end
end
end
end
100 changes: 100 additions & 0 deletions lib/qingcloud/sdk/service/notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2016 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or 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.
# +-------------------------------------------------------------------------

require "active_support/core_ext/hash/keys"

module QingCloud
module SDK
class NotificationService
attr_accessor :config, :properties

def initialize(config, properties)
self.config = config
self.properties = properties.deep_symbolize_keys
end

def describe_notification_lists(limit: nil, notification_lists: [], offset: nil, owner: "")
input = {
config: config,
properties: properties,
api_name: "DescribeNotificationLists",
request_method: "GET",
request_params: {
"limit" => limit,
"notification_lists" => notification_lists,
"offset" => offset,
"owner" => owner,
},
}

describe_notification_lists_input_validate input

request = Request.new input
request.send
end

def send_alarm_notification(notification_data: [], notification_list_id: "", resource_id: "", resource_name: "", resource_type: "", user_id: "")
input = {
config: config,
properties: properties,
api_name: "SendAlarmNotification",
request_method: "GET",
request_params: {
"notification_data" => notification_data,
"notification_list_id" => notification_list_id,
"resource_id" => resource_id,
"resource_name" => resource_name,
"resource_type" => resource_type,
"user_id" => user_id,
},
}

send_alarm_notification_input_validate input

request = Request.new input
request.send
end

private

def describe_notification_lists_input_validate(input)
input.deep_stringify_keys!

if input["request_params"]["notification_lists"].to_s.empty?
raise ParameterRequiredError.new("notification_lists", "DescribeNotificationListsInput")
end
end

def send_alarm_notification_input_validate(input)
input.deep_stringify_keys!

if input["request_params"]["notification_data"].to_s.empty?
raise ParameterRequiredError.new("notification_data", "SendAlarmNotificationInput")
end

input["request_params"]["notification_data"].map { |x| }

if input["request_params"]["notification_list_id"].to_s.empty?
raise ParameterRequiredError.new("notification_list_id", "SendAlarmNotificationInput")
end

if input["request_params"]["user_id"].to_s.empty?
raise ParameterRequiredError.new("user_id", "SendAlarmNotificationInput")
end
end
end
end
end
7 changes: 7 additions & 0 deletions lib/qingcloud/sdk/service/qingcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def nic(zone)
NicService.new(self.config, self.properties.merge(properties))
end

def notification(zone)
properties = {
"zone" => zone,
}
NotificationService.new(self.config, self.properties.merge(properties))
end

def project(zone)
properties = {
"zone" => zone,
Expand Down
26 changes: 26 additions & 0 deletions lib/qingcloud/sdk/service/security_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ def apply_security_group(instances: [], security_group: "")
request.send
end

# Documentation URL: https://docs.qingcloud.com/api/sg/apply_security_group_ipsets.html
def apply_security_group_ip_sets(security_group_ipsets: [])
input = {
config: config,
properties: properties,
api_name: "ApplySecurityGroupIPSets",
request_method: "GET",
request_params: {
"security_group_ipsets" => security_group_ipsets,
},
}

apply_security_group_ip_sets_input_validate input

request = Request.new input
request.send
end

# Documentation URL: https://docs.qingcloud.com/api/sg/create_security_group.html
def create_security_group(security_group_name: "")
input = {
Expand Down Expand Up @@ -423,6 +441,14 @@ def apply_security_group_input_validate(input)
end
end

def apply_security_group_ip_sets_input_validate(input)
input.deep_stringify_keys!

if input["request_params"]["security_group_ipsets"].to_s.empty?
raise ParameterRequiredError.new("security_group_ipsets", "ApplySecurityGroupIPSetsInput")
end
end

def create_security_group_input_validate(input)
input.deep_stringify_keys!
end
Expand Down
3 changes: 2 additions & 1 deletion lib/qingcloud/sdk/service/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_snapshots(is_full: nil, resources: [], service_params: "", snapshot_n
end

# Documentation URL: https://docs.qingcloud.com/api/snapshot/create_volume_from_snapshot.html
def create_volume_from_snapshot(snapshot: "", volume_name: "")
def create_volume_from_snapshot(snapshot: "", volume_name: "", zone: "")
input = {
config: config,
properties: properties,
Expand All @@ -94,6 +94,7 @@ def create_volume_from_snapshot(snapshot: "", volume_name: "")
request_params: {
"snapshot" => snapshot,
"volume_name" => volume_name,
"zone" => zone,
},
}

Expand Down
18 changes: 10 additions & 8 deletions lib/qingcloud/sdk/service/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def clone_volumes(count: nil, sub_zones: "", volume: "", volume_name: "", volume
"sub_zones" => sub_zones,
"volume" => volume,
"volume_name" => volume_name,
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 10, 100, 200
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 6, 10, 100, 200
"zone" => zone,
},
}
Expand All @@ -69,7 +69,7 @@ def clone_volumes(count: nil, sub_zones: "", volume: "", volume_name: "", volume
end

# Documentation URL: https://docs.qingcloud.com/api/volume/create_volumes.html
def create_volumes(count: nil, repl: "", size: nil, volume_name: "", volume_type: nil)
def create_volumes(count: nil, repl: "", size: nil, volume_name: "", volume_type: nil, zone: "")
input = {
config: config,
properties: properties,
Expand All @@ -80,7 +80,8 @@ def create_volumes(count: nil, repl: "", size: nil, volume_name: "", volume_type
"repl" => repl,
"size" => size,
"volume_name" => volume_name,
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 10, 100, 200
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 6, 10, 100, 200
"zone" => zone,
},
}

Expand Down Expand Up @@ -109,7 +110,7 @@ def delete_volumes(volumes: [])
end

# Documentation URL: https://docs.qingcloud.com/api/volume/describe_volumes.html
def describe_volumes(limit: nil, offset: nil, owner: "", project_id: "", search_word: "", status: [], tags: [], verbose: nil, volume_type: nil, volumes: [])
def describe_volumes(limit: nil, offset: nil, owner: "", project_id: "", search_word: "", status: [], tags: [], verbose: nil, volume_type: nil, volumes: [], zone: "")
input = {
config: config,
properties: properties,
Expand All @@ -124,8 +125,9 @@ def describe_volumes(limit: nil, offset: nil, owner: "", project_id: "", search_
"status" => status,
"tags" => tags,
"verbose" => verbose, # verbose's available values: 0, 1
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 10, 100, 200
"volume_type" => volume_type, # volume_type's available values: 0, 1, 2, 3, 4, 5, 6, 10, 100, 200
"volumes" => volumes,
"zone" => zone,
},
}

Expand Down Expand Up @@ -215,7 +217,7 @@ def clone_volumes_input_validate(input)
end

unless input["request_params"]["volume_type"].to_s.empty?
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "10", "100", "200"]
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "6", "10", "100", "200"]
unless volume_type_valid_values.include? input["request_params"]["volume_type"].to_s
raise ParameterValueNotAllowedError.new(
"volume_type",
Expand All @@ -234,7 +236,7 @@ def create_volumes_input_validate(input)
end

unless input["request_params"]["volume_type"].to_s.empty?
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "10", "100", "200"]
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "6", "10", "100", "200"]
unless volume_type_valid_values.include? input["request_params"]["volume_type"].to_s
raise ParameterValueNotAllowedError.new(
"volume_type",
Expand Down Expand Up @@ -268,7 +270,7 @@ def describe_volumes_input_validate(input)
end

unless input["request_params"]["volume_type"].to_s.empty?
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "10", "100", "200"]
volume_type_valid_values = ["0", "1", "2", "3", "4", "5", "6", "10", "100", "200"]
unless volume_type_valid_values.include? input["request_params"]["volume_type"].to_s
raise ParameterValueNotAllowedError.new(
"volume_type",
Expand Down
Loading