mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
refactored duplicate parser code, added more request tests, converted all parser responses to be key,value pairs
This commit is contained in:
parent
fad43b8694
commit
a79aad91e0
39 changed files with 842 additions and 141 deletions
|
@ -18,7 +18,7 @@ module Fog
|
|||
super
|
||||
case name
|
||||
when 'Cluster'
|
||||
@response = @cluster
|
||||
@response = {name => @cluster}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,13 +127,13 @@ module Fog
|
|||
@in_pending_modified_values = false
|
||||
|
||||
when 'ClusterParameterGroup'
|
||||
@cluster['ClusterParameterGroups'] << @cluster_parameter_group
|
||||
@cluster['ClusterParameterGroups'] << {name => @cluster_parameter_group}
|
||||
@cluster_parameter_group = {}
|
||||
when 'ClusterSecurityGroup'
|
||||
@cluster['ClusterSecurityGroups'] << @cluster_security_group
|
||||
@cluster['ClusterSecurityGroups'] << {name => @cluster_security_group}
|
||||
@cluster_security_group = {}
|
||||
when 'VpcSecurityGroup'
|
||||
@cluster['VpcSecurityGroups'] << @vpc_security_group
|
||||
@cluster['VpcSecurityGroups'] << {name => @vpc_security_group}
|
||||
@vpc_security_group = {}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ module Fog
|
|||
when 'EC2SecurityGroupName', 'EC2SecurityGroupOwnerId', 'CIDRIP', 'Status'
|
||||
@list[name] = value
|
||||
when 'EC2SecurityGroup', 'IPRange'
|
||||
@cluster_security_group[@list_name] << @list
|
||||
@cluster_security_group[@list_name] << {name => @list}
|
||||
@list = {}
|
||||
end
|
||||
end
|
||||
|
|
32
lib/fog/aws/parsers/redshift/cluster_snapshot.rb
Normal file
32
lib/fog/aws/parsers/redshift/cluster_snapshot.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot_parser'
|
||||
|
||||
class ClusterSnapshot < ClusterSnapshotParser
|
||||
# :parameter_group_name - (String)
|
||||
# :parameter_group_status - (String)
|
||||
|
||||
def reset
|
||||
super
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'Snapshot'
|
||||
@response = @snapshot
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -30,7 +30,11 @@ module Fog
|
|||
# :elapsed_time_in_seconds - (Integer)
|
||||
|
||||
def reset
|
||||
@response = { 'AccountsWithRestoreAccess' => [] }
|
||||
@snapshot = fresh_snapshot
|
||||
end
|
||||
|
||||
def fresh_snapshot
|
||||
{'Snapshot' => { 'AccountsWithRestoreAccess' => [] }}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
|
@ -42,17 +46,17 @@ module Fog
|
|||
case name
|
||||
when 'SnapshotIdentifier', 'ClusterIdentifier', 'Status', 'AvailabilityZone', 'MasterUsername', 'ClusterVersion', 'SnapshotType', 'NodeType',
|
||||
'DBName', 'VpcId', 'OwnerAccount'
|
||||
@response[name] = value
|
||||
@snapshot['Snapshot'][name] = value
|
||||
when 'Port', 'NumberOfNodes', 'ElapsedTimeInSeconds', 'EstimatedSecondsToCompletion'
|
||||
@response[name] = value.to_i
|
||||
@snapshot['Snapshot'][name] = value.to_i
|
||||
when 'SnapshotCreateTime', 'ClusterCreateTime'
|
||||
@response[name] = Time.parse(value)
|
||||
@snapshot['Snapshot'][name] = Time.parse(value)
|
||||
when 'Encrypted'
|
||||
@response[name] = (value == true)
|
||||
@snapshot['Snapshot'][name] = (value == true)
|
||||
when 'TotalBackupSizeInMegaBytes', 'ActualIncrementalBackupSizeInMegaBytes', 'BackupProgressInMegaBytes', 'CurrentBackupRateInMegaBytesPerSecond'
|
||||
@response[name] = value.to_f
|
||||
@snapshot['Snapshot'][name] = value.to_f
|
||||
when 'AccountId'
|
||||
@response['AccountsWithRestoreAccess'] << value
|
||||
@snapshot['Snapshot']['AccountsWithRestoreAccess'] << value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ module Fog
|
|||
when 'Name'
|
||||
@subnet['SubnetAvailabilityZone'][name] = value
|
||||
when 'Subnet'
|
||||
@response['Subnets'] << @subnet
|
||||
@response['Subnets'] << {name => @subnet}
|
||||
@subnet = fresh_subnet
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
# :description - (String)
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
@response = {'ClusterParameterGroup'=>{}}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
super
|
||||
case name
|
||||
when 'ParameterGroupName', 'ParameterGroupFamily', 'Description'
|
||||
@response[name] = value
|
||||
@response['ClusterParameterGroup'][name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
when 'ParameterGroupName', 'ParameterGroupFamily', 'Description'
|
||||
@parameter_group[name] = value
|
||||
when 'ClusterParameterGroup'
|
||||
@response['ParameterGroups'] << @parameter_group
|
||||
@response['ParameterGroups'] << {name => @parameter_group}
|
||||
@parameter_group = {}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ module Fog
|
|||
when 'IsModifiable'
|
||||
@parameter[name] = (value == true)
|
||||
when 'Parameter'
|
||||
@response['Parameters'] << @parameter
|
||||
@response['Parameters'] << {name => @parameter}
|
||||
@parameter = {}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module Fog
|
|||
when 'Marker'
|
||||
@response[name] = value
|
||||
when 'ClusterSecurityGroup'
|
||||
@response['ClusterSecurityGroups'] << @cluster_security_group
|
||||
@response['ClusterSecurityGroups'] << { name => @cluster_security_group }
|
||||
@cluster_security_group = fresh_cluster_security_group
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,42 +3,16 @@ module Fog
|
|||
module Redshift
|
||||
module AWS
|
||||
|
||||
class DescribeClusterSnapshots < Fog::Parsers::Base
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot_parser'
|
||||
|
||||
class DescribeClusterSnapshots < ClusterSnapshotParser
|
||||
# :marker - (String)
|
||||
# :snapshots - (Array)
|
||||
# :snapshot_identifier - (String)
|
||||
# :cluster_identifier - (String)
|
||||
# :snapshot_create_time - (Time)
|
||||
# :status - (String)
|
||||
# :port - (Integer)
|
||||
# :availability_zone - (String)
|
||||
# :cluster_create_time - (Time)
|
||||
# :master_username - (String)
|
||||
# :cluster_version - (String)
|
||||
# :snapshot_type - (String)
|
||||
# :node_type - (String)
|
||||
# :number_of_nodes - (Integer)
|
||||
# :db_name - (String)
|
||||
# :vpc_id - (String)
|
||||
# :encrypted - (Boolean)
|
||||
# :accounts_with_restore_access - (Array)
|
||||
# :account_id - (String)
|
||||
# :owner_account - (String)
|
||||
# :total_backup_size_in_mega_bytes - (Numeric)
|
||||
# :actual_incremental_backup_size_in_mega_bytes - (Numeric)
|
||||
# :backup_progress_in_mega_bytes - (Numeric)
|
||||
# :current_backup_rate_in_mega_bytes_per_second - (Numeric)
|
||||
# :estimated_seconds_to_completion - (Integer)
|
||||
# :elapsed_time_in_seconds - (Integer)
|
||||
|
||||
def reset
|
||||
@response = { 'Snapshots' => [] }
|
||||
end
|
||||
|
||||
def fresh_snapshot
|
||||
{'AccountsWithRestoreAccess' => []}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
|
@ -52,20 +26,6 @@ module Fog
|
|||
case name
|
||||
when 'Marker'
|
||||
@response[name] = value
|
||||
when 'SnapshotIdentifier', 'ClusterIdentifier', 'Status', 'AvailabilityZone', 'MasterUsername', 'ClusterVersion',
|
||||
'SnapshotType', 'NodeType', 'DBName', 'VpcId', 'OwnerAccount'
|
||||
@snapshot[name] = value
|
||||
when 'SnapshotCreateTime', 'ClusterCreateTime'
|
||||
@snapshot[name] = Time.parse(value)
|
||||
when 'Port', 'NumberOfNodes', 'EstimatedSecondsToCompletion', 'ElapsedTimeInSeconds'
|
||||
@snapshot[name] = value.to_i
|
||||
when 'Encrypted'
|
||||
@snapshot[name] = value == true
|
||||
when 'AccountId'
|
||||
@snapshot['AccountsWithRestoreAccess'] << value
|
||||
when 'CurrentBackupRateInMegaBytesPerSecond', 'BackupProgressInMegaBytes', 'ActualIncrementalBackupSizeInMegaBytes',
|
||||
'TotalBackupSizeInMegaBytes'
|
||||
@snapshot[name] = value.to_f
|
||||
when 'Snapshot'
|
||||
@response['Snapshots'] << @snapshot
|
||||
@snapshot = fresh_snapshot
|
||||
|
|
|
@ -34,12 +34,12 @@ module Fog
|
|||
when 'Marker'
|
||||
@response[name] = value
|
||||
when 'ClusterSubnetGroup'
|
||||
@response['ClusterSubnetGroups'] << @cluster_subnet_group
|
||||
@response['ClusterSubnetGroups'] << {name => @cluster_subnet_group}
|
||||
@cluster_subnet_group = {'Subnets' => []}
|
||||
when 'ClusterSubnetGroupName', 'Description', 'VpcId', 'SubnetGroupStatus'
|
||||
@cluster_subnet_group[name] = value
|
||||
when 'Subnet'
|
||||
@cluster_subnet_group['Subnets'] << @subnet if @subnet
|
||||
@cluster_subnet_group['Subnets'] << {name => @subnet} if @subnet
|
||||
@subnet = {}
|
||||
when 'SubnetAvailabilityZone'
|
||||
@subnet['SubnetAvailabilityZone'] = {}
|
||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
|||
when 'ClusterVersion'
|
||||
@cluster_version_depth -= 1
|
||||
if @cluster_version_depth == 0
|
||||
@response['ClusterVersions'] << @cluster_version
|
||||
@response['ClusterVersions'] << {name => @cluster_version}
|
||||
@cluster_version = {}
|
||||
else
|
||||
@cluster_version[name] = value
|
||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
super
|
||||
case name
|
||||
when 'Cluster'
|
||||
@response["ClusterSet"] << @cluster
|
||||
@response["ClusterSet"] << {name => @cluster}
|
||||
@cluster = fresh_cluster
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
when 'IsModifiable'
|
||||
@parameter[name] = (value == true)
|
||||
when 'Parameter'
|
||||
@response['Parameters'] << @parameter
|
||||
@response['Parameters'] << {name => @parameter}
|
||||
@parameter = {}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
when 'Date'
|
||||
@event[name] = Time.parse(value)
|
||||
when 'Event'
|
||||
@response['Events'] << @event
|
||||
@response['Events'] << {name => @event}
|
||||
@event = {}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,10 +40,10 @@ module Fog
|
|||
when 'Name'
|
||||
@availability_zone[name] = value
|
||||
when 'AvailabilityZone'
|
||||
@orderable_cluster_option['AvailabilityZones'] << @availability_zone
|
||||
@orderable_cluster_option['AvailabilityZones'] << {name => @availability_zone}
|
||||
@availability_zone = {}
|
||||
when 'OrderableClusterOption'
|
||||
@response['OrderableClusterOptions'] << @orderable_cluster_option
|
||||
@response['OrderableClusterOptions'] << {name => @orderable_cluster_option}
|
||||
@orderable_cluster_option = fresh_orderable_cluster_option
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,10 +50,10 @@ module Fog
|
|||
when 'RecurringChargeFrequency'
|
||||
@recurring_charge[name] = value
|
||||
when 'RecurringCharge'
|
||||
@reserved_node_offering['RecurringCharges'] << @recurring_charge
|
||||
@reserved_node_offering['RecurringCharges'] << {name => @recurring_charge}
|
||||
@recurring_charge = {}
|
||||
when 'ReservedNodeOffering'
|
||||
@response['ReservedNodeOfferings'] << @reserved_node_offering
|
||||
@response['ReservedNodeOfferings'] << {name => @reserved_node_offering}
|
||||
@reserved_node_offering = fresh_reserved_node_offering
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,10 +57,10 @@ module Fog
|
|||
when 'RecurringChargeFrequency'
|
||||
@recurring_charge[name] = value
|
||||
when 'RecurringCharge'
|
||||
@reserved_node['RecurringCharges'] << @recurring_charge
|
||||
@reserved_node['RecurringCharges'] << {name => @recurring_charge}
|
||||
@recurring_charge = {}
|
||||
when 'ReservedNode'
|
||||
@response['ReservedNodes'] << @reserved_node
|
||||
@response['ReservedNodes'] << {name => @reserved_node}
|
||||
@reserved_node = fresh_reserved_node
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
|
||||
class PurchaseReservedNodeOffering < Fog::Parsers::Base
|
||||
|
||||
# :reserved_node_id - (String)
|
||||
# :reserved_node_offering_id - (String)
|
||||
# :node_type - (String)
|
||||
# :start_time - (Time)
|
||||
# :duration - (Integer)
|
||||
# :fixed_price - (Numeric)
|
||||
# :usage_price - (Numeric)
|
||||
# :currency_code - (String)
|
||||
# :node_count - (Integer)
|
||||
# :state - (String)
|
||||
# :offering_type - (String)
|
||||
# :recurring_charges - (Array)
|
||||
# :recurring_charge_amount - (Numeric)
|
||||
# :recurring_charge_frequency - (String)
|
||||
def reset
|
||||
@response = { 'RecurringCharges' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'RecurringCharges'
|
||||
@recurring_charge = {}
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'ReservedNodeId', 'ReservedNodeOfferingId', 'NodeType', 'CurrencyCode', 'State', 'OfferingType'
|
||||
@response[name] = value
|
||||
when 'Duration', 'NodeCount'
|
||||
@response[name] = value.to_i
|
||||
when 'FixedPrice', 'UsagePrice'
|
||||
@response[name] = value.to_f
|
||||
when 'StartTime'
|
||||
@response[name] = Time.parse(value)
|
||||
when 'RecurringChargeAmount'
|
||||
@recurring_charge[name] = value.to_f
|
||||
when 'RecurringChargeFrequency'
|
||||
@recurring_charge[name] = value
|
||||
when 'RecurringCharge'
|
||||
@response['RecurringCharges'] << {name => @recurring_charge}
|
||||
@recurring_charge = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
|
||||
require 'fog/aws/parsers/redshift/cluster_security_group_parser'
|
||||
|
||||
class RevokeClusterSecurityGroupIngress < ClusterSecurityGroupParser
|
||||
# :cluster_security_group
|
||||
|
||||
def reset
|
||||
super
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'ClusterSecurityGroup'
|
||||
@response['ClusterSecurityGroup'] = @cluster_security_group
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
module Redshift
|
||||
module AWS
|
||||
|
||||
class ModifyClusterParameterGroup < Fog::Parsers::Base
|
||||
class UpdateClusterParameterGroupParser < Fog::Parsers::Base
|
||||
# :parameter_group_name - (String)
|
||||
# :parameter_group_status - (String)
|
||||
|
|
@ -36,15 +36,15 @@ module Fog
|
|||
request :delete_cluster_security_group
|
||||
request :delete_cluster_snapshot
|
||||
request :delete_cluster_subnet_group
|
||||
# request :authorize_cluster_security_group_ingress
|
||||
# request :authorize_snapshot_access
|
||||
# request :copy_cluster_snapshot
|
||||
# request :purchase_reserved_node_offering
|
||||
request :authorize_cluster_security_group_ingress
|
||||
request :authorize_snapshot_access
|
||||
request :copy_cluster_snapshot
|
||||
request :purchase_reserved_node_offering
|
||||
request :reboot_cluster
|
||||
# request :reset_cluster_parameter_group
|
||||
# request :restore_from_cluster_snapshot
|
||||
# request :revoke_cluster_security_group_ingress
|
||||
# request :revoke_snapshot_access
|
||||
request :reset_cluster_parameter_group
|
||||
request :restore_from_cluster_snapshot
|
||||
request :revoke_cluster_security_group_ingress
|
||||
request :revoke_snapshot_access
|
||||
|
||||
class Mock
|
||||
|
||||
|
@ -118,9 +118,6 @@ module Fog
|
|||
params[:headers]['Authorization'] = @signer.sign params, date
|
||||
|
||||
response = @connection.request(params.merge(:parser => parser), &block)
|
||||
if response.headers['Content-Type'] == 'application/json' && response.body.size > 0 #body will be empty if the streaming form has been used
|
||||
response.body = Fog::JSON.decode(response.body)
|
||||
end
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/revoke_cluster_security_group_ingress'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :cluster_security_group_name - required - (String)
|
||||
# The name of the security Group from which to revoke the ingress rule.
|
||||
# * :cidrip - (String)
|
||||
# The IP range for which to revoke access. This range must be a valid Classless
|
||||
# Inter-Domain Routing (CIDR) block of IP addresses. If CIDRIP is specified,
|
||||
# EC2SecurityGroupName and EC2SecurityGroupOwnerId cannot be provided.
|
||||
# * :ec2_security_group_name - (String)
|
||||
# The name of the EC2 Security Group whose access is to be revoked. If
|
||||
# EC2SecurityGroupName is specified, EC2SecurityGroupOwnerId must also be
|
||||
# provided and CIDRIP cannot be provided.
|
||||
# * :ec2_security_group_owner_id - (String)
|
||||
# The AWS account number of the owner of the security group specified in the
|
||||
# EC2SecurityGroupName parameter. The AWS access key ID is not an acceptable
|
||||
# value. If EC2SecurityGroupOwnerId is specified, EC2SecurityGroupName must
|
||||
# also be provided. and CIDRIP cannot be provided. Example: 111122223333
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_AuthorizeClusterSecurityGroupIngress.html
|
||||
def authorize_cluster_security_group_ingress(options = {})
|
||||
cluster_security_group_name = options[:cluster_security_group_name]
|
||||
cidrip = options[:cidrip]
|
||||
ec2_security_group_name = options[:ec2_security_group_name]
|
||||
ec2_security_group_owner_id = options[:ec2_security_group_owner_id]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::RevokeClusterSecurityGroupIngress.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'AuthorizeClusterSecurityGroupIngress'
|
||||
params[:query]['ClusterSecurityGroupName'] = cluster_security_group_name if cluster_security_group_name
|
||||
params[:query]['CIDRIP'] = cidrip if cidrip
|
||||
params[:query]['EC2SecurityGroupName'] = ec2_security_group_name if ec2_security_group_name
|
||||
params[:query]['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id if ec2_security_group_owner_id
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
43
lib/fog/aws/requests/redshift/authorize_snapshot_access.rb
Normal file
43
lib/fog/aws/requests/redshift/authorize_snapshot_access.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :snapshot_identifier - required - (String)
|
||||
# The identifier of the snapshot the account is authorized to restore.
|
||||
# * :snapshot_cluster_identifier - (String)
|
||||
# * :account_with_restore_access - required - (String)
|
||||
# The identifier of the AWS customer account authorized to restore the specified snapshot. #
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_CopyClusterSnapshot.html
|
||||
def authorize_snapshot_access(options = {})
|
||||
snapshot_identifier = options[:snapshot_identifier]
|
||||
snapshot_cluster_identifier = options[:snapshot_cluster_identifier]
|
||||
account_with_restore_access = options[:account_with_restore_access]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshot.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'AuthorizeSnapshotAccess'
|
||||
params[:query]['SnapshotIdentifier'] = snapshot_identifier if snapshot_identifier
|
||||
params[:query]['SnapshotClusterIdentifier'] = snapshot_cluster_identifier if snapshot_cluster_identifier
|
||||
params[:query]['AccountWithRestoreAccess'] = account_with_restore_access if account_with_restore_access
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
48
lib/fog/aws/requests/redshift/copy_cluster_snapshot.rb
Normal file
48
lib/fog/aws/requests/redshift/copy_cluster_snapshot.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :source_snapshot_identifier - required - (String)
|
||||
# The identifier for the source snapshot. Constraints: Must be the identifier for
|
||||
# a valid automated snapshot whose state is "available".
|
||||
# * :source_snapshot_cluster_identifier - (String)
|
||||
# * :target_snapshot_identifier - required - (String)
|
||||
# The identifier given to the new manual snapshot. Constraints: Cannot be null,
|
||||
# empty, or blank. Must contain from 1 to 255 alphanumeric characters or hyphens.
|
||||
# First character must be a letter. Cannot end with a hyphen or contain two
|
||||
# consecutive hyphens. Must be unique for the AWS account that is making the request.
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_CopyClusterSnapshot.html
|
||||
def copy_cluster_snapshot(options = {})
|
||||
source_snapshot_identifier = options[:source_snapshot_identifier]
|
||||
source_snapshot_cluster_identifier = options[:source_snapshot_cluster_identifier]
|
||||
target_snapshot_identifier = options[:target_snapshot_identifier]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshot.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'CopyClusterSnapshot'
|
||||
params[:query]['SourceSnapshotIdentifier'] = source_snapshot_identifier if source_snapshot_identifier
|
||||
params[:query]['SourceSnapshotClusterIdentifier'] = source_snapshot_cluster_identifier if source_snapshot_cluster_identifier
|
||||
params[:query]['TargetSnapshotIdentifier'] = target_snapshot_identifier if target_snapshot_identifier
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot_parser'
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -28,7 +28,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshotParser.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshot.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'CreateClusterSnapshot'
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot_parser'
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -28,7 +28,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshotParser.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshot.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'DeleteClusterSnapshot'
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/modify_cluster_parameter_group'
|
||||
require 'fog/aws/parsers/redshift/update_cluster_parameter_group_parser'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -22,7 +22,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ModifyClusterParameterGroup.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::UpdateClusterParameterGroupParser.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'ModifyClusterParameterGroup'
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/purchase_reserved_node_offering'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :reserved_node_offering_id - required - (String)
|
||||
# The unique identifier of the reserved node offering you want to purchase.
|
||||
# * :node_count - (Integer)
|
||||
# The number of reserved nodes you want to purchase. Default: 1
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_PurchaseReservedNodeOffering.html
|
||||
def purchase_reserved_node_offering(options = {})
|
||||
reserved_node_offering_id = options[:reserved_node_offering_id]
|
||||
node_count = options[:node_count]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::PurchaseReservedNodeOffering.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'PurchaseReservedNodeOffering'
|
||||
params[:query]['ReservedNodeOfferingId'] = reserved_node_offering_id if reserved_node_offering_id
|
||||
params[:query]['NodeCount'] = node_count if node_count
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_DeleteCluster.html
|
||||
def reboot_cluster(options = {})
|
||||
cluster_identifier = options[:cluster_identifier]
|
||||
cluster_identifier = options[:cluster_identifier]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
|
@ -29,6 +29,7 @@ module Fog
|
|||
params[:query]['Action'] = 'RebootCluster'
|
||||
params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier
|
||||
request(params)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/update_cluster_parameter_group_parser'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :parameter_group_name - required - (String) The name of the cluster parameter group to be reset.
|
||||
# * :reset_all_parameters - (Boolean) If true , all parameters in the specified parameter group will be reset to their default values. Default: true
|
||||
# * :parameters - (Array<) An array of names of parameters to be reset. If ResetAllParameters option is not used, then at least one parameter name must be supplied. Constraints: A maximum of 20 parameters can be reset in a single request.
|
||||
# * :parameter_name - (String) The name of the parameter.
|
||||
# * :parameter_value - (String) The value of the parameter.
|
||||
# * :description - (String) A description of the parameter.
|
||||
# * :source - (String) The source of the parameter value, such as "engine-default" or "user".
|
||||
# * :data_type - (String) The data type of the parameter.
|
||||
# * :allowed_values - (String) The valid range of values for the parameter.
|
||||
# * :is_modifiable - (Boolean) If true , the parameter can be modified. Some parameters have security or operational implications that prevent them from being changed.
|
||||
# * :minimum_engine_version - (String) The earliest engine version to which the parameter can apply.
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_ResetClusterParameterGroup.html
|
||||
def reset_cluster_parameter_group(options = {})
|
||||
parameter_group_name = options[:parameter_group_name]
|
||||
reset_all_parameters = options[:reset_all_parameters]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:idempotent => true,
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::UpdateClusterParameterGroupParser.new
|
||||
}
|
||||
|
||||
if options['Parameters']
|
||||
options['Parameters'].keys.each_with_index do |name, index|
|
||||
params[:query].merge!({
|
||||
"Parameters.member.#{index+1}.#{name}" => options['Parameters'][name]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
params[:query]['Action'] = 'ResetClusterSubnetGroup'
|
||||
params[:query]['ParameterGroupName'] = parameter_group_name if parameter_group_name
|
||||
params[:query]['ResetAllParameters'] = reset_all_parameters if reset_all_parameters
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :cluster_identifier - required - (String)
|
||||
# The identifier of the cluster that will be created from restoring the snapshot.
|
||||
# Constraints: Must contain from 1 to 63 alphanumeric characters or hyphens.
|
||||
# Alphabetic characters must be lowercase. First character must be a letter. Cannot
|
||||
# end with a hyphen or contain two consecutive hyphens. Must be unique for all
|
||||
# clusters within an AWS account.
|
||||
# * :snapshot_identifier - required - (String)
|
||||
# The name of the snapshot from which to create the new cluster. This parameter
|
||||
# isn't case sensitive. Example: my-snapshot-id
|
||||
# * :snapshot_cluster_identifier - (String)
|
||||
# * :port - (Integer)
|
||||
# The port number on which the cluster accepts connections. Default: The same port
|
||||
# as the original cluster. Constraints: Must be between 1115 and 65535.
|
||||
# * :availability_zone - (String)
|
||||
# The Amazon EC2 Availability Zone in which to restore the cluster. Default: A
|
||||
# random, system-chosen Availability Zone. Example: us-east-1a
|
||||
# * :allow_version_upgrade - (Boolean)
|
||||
# If true , upgrades can be applied during the maintenance window to the Amazon
|
||||
# Redshift engine that is running on the cluster. Default: true
|
||||
# * :cluster_subnet_group_name - (String)
|
||||
# The name of the subnet group where you want to cluster restored. A snapshot of
|
||||
# cluster in VPC can be restored only in VPC. Therefore, you must provide subnet
|
||||
# group name where you want the cluster restored.
|
||||
# * :publicly_accessible - (Boolean)
|
||||
# If true , the cluster can be accessed from a public network.
|
||||
# * :owner_account - (String)
|
||||
# The AWS customer account used to create or copy the snapshot. Required if you are
|
||||
# restoring a snapshot you do not own, optional if you own the snapshot.
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_RestoreFromClusterSnapshot.html
|
||||
def restore_from_cluster_snapshot(options = {})
|
||||
cluster_identifier = options[:cluster_identifier]
|
||||
snapshot_identifier = options[:snapshot_identifier]
|
||||
snapshot_cluster_identifier = options[:snapshot_cluster_identifier]
|
||||
port = options[:port]
|
||||
availability_zone = options[:availability_zone]
|
||||
allow_version_upgrade = options[:allow_version_upgrade]
|
||||
cluster_subnet_group_name = options[:cluster_subnet_group_name]
|
||||
publicly_accessible = options[:publicly_accessible]
|
||||
owner_account = options[:owner_account]
|
||||
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'RestoreFromClusterSnapshot'
|
||||
params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier
|
||||
params[:query]['SnapshotIdentifier'] = snapshot_identifier if snapshot_identifier
|
||||
params[:query]['SnapshotClusterIdentifier'] = snapshot_cluster_identifier if snapshot_cluster_identifier
|
||||
params[:query]['Port'] = port if port
|
||||
params[:query]['AvailabilityZone'] = availability_zone if availability_zone
|
||||
params[:query]['AllowVersionUpgrade'] = allow_version_upgrade if allow_version_upgrade
|
||||
params[:query]['ClusterSubnetGroupName'] = cluster_subnet_group_name if cluster_subnet_group_name
|
||||
params[:query]['PubliclyAccessible'] = publicly_accessible if publicly_accessible
|
||||
params[:query]['OwnerAccount'] = owner_account if owner_account
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/revoke_cluster_security_group_ingress'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :cluster_security_group_name - required - (String)
|
||||
# The name of the security Group from which to revoke the ingress rule.
|
||||
# * :cidrip - (String)
|
||||
# The IP range for which to revoke access. This range must be a valid Classless
|
||||
# Inter-Domain Routing (CIDR) block of IP addresses. If CIDRIP is specified,
|
||||
# EC2SecurityGroupName and EC2SecurityGroupOwnerId cannot be provided.
|
||||
# * :ec2_security_group_name - (String)
|
||||
# The name of the EC2 Security Group whose access is to be revoked. If
|
||||
# EC2SecurityGroupName is specified, EC2SecurityGroupOwnerId must also be
|
||||
# provided and CIDRIP cannot be provided.
|
||||
# * :ec2_security_group_owner_id - (String)
|
||||
# The AWS account number of the owner of the security group specified in the
|
||||
# EC2SecurityGroupName parameter. The AWS access key ID is not an acceptable
|
||||
# value. If EC2SecurityGroupOwnerId is specified, EC2SecurityGroupName must
|
||||
# also be provided. and CIDRIP cannot be provided. Example: 111122223333
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_RevokeClusterSecurityGroupIngress.html
|
||||
def revoke_cluster_security_group_ingress(options = {})
|
||||
cluster_security_group_name = options[:cluster_security_group_name]
|
||||
cidrip = options[:cidrip]
|
||||
ec2_security_group_name = options[:ec2_security_group_name]
|
||||
ec2_security_group_owner_id = options[:ec2_security_group_owner_id]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::RevokeClusterSecurityGroupIngress.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'RevokeClusterSecurityGroupIngress'
|
||||
params[:query]['ClusterSecurityGroupName'] = cluster_security_group_name if cluster_security_group_name
|
||||
params[:query]['CIDRIP'] = cidrip if cidrip
|
||||
params[:query]['EC2SecurityGroupName'] = ec2_security_group_name if ec2_security_group_name
|
||||
params[:query]['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id if ec2_security_group_owner_id
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
44
lib/fog/aws/requests/redshift/revoke_snapshot_access.rb
Normal file
44
lib/fog/aws/requests/redshift/revoke_snapshot_access.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_snapshot'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :snapshot_identifier - required - (String)
|
||||
# The identifier of the snapshot that the account can no longer access.
|
||||
# * :snapshot_cluster_identifier - (String)
|
||||
# * :account_with_restore_access - required - (String)
|
||||
# The identifier of the AWS customer account that can no longer restore the specified snapshot.
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_RevokeSnapshotAccess.html
|
||||
def revoke_snapshot_access(options = {})
|
||||
snapshot_identifier = options[:snapshot_identifier]
|
||||
snapshot_cluster_identifier = options[:snapshot_cluster_identifier]
|
||||
account_with_restore_access = options[:account_with_restore_access]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:expects => 200,
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterSnapshot.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'RevokeSnapshotAccess'
|
||||
params[:query]['SnapshotIdentifier'] = snapshot_identifier if snapshot_identifier
|
||||
params[:query]['SnapshotClusterIdentifier'] = snapshot_cluster_identifier if snapshot_cluster_identifier
|
||||
params[:query]['AccountWithRestoreAccess'] = account_with_restore_access if account_with_restore_access
|
||||
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
77
tests/aws/requests/redshift/cluster_parameter_group_tests.rb
Normal file
77
tests/aws/requests/redshift/cluster_parameter_group_tests.rb
Normal file
|
@ -0,0 +1,77 @@
|
|||
Shindo.tests('Fog::Redshift[:aws] | cluster parameter group requests', ['aws']) do
|
||||
|
||||
suffix = rand(65536).to_s(16)
|
||||
parameter_group = "test-cluster-parameter-group-#{suffix}"
|
||||
|
||||
@cluster_parameter_format = {
|
||||
'Parameter' => {
|
||||
"ParameterValue" => String,
|
||||
"DataType" => String,
|
||||
"Source" => String,
|
||||
"IsModifiable" => Fog::Boolean,
|
||||
"Description" => String,
|
||||
"ParameterName" => String
|
||||
}
|
||||
}
|
||||
|
||||
@cluster_parameters_format = {
|
||||
"Parameters"=> [@cluster_parameter_format]
|
||||
}
|
||||
|
||||
@cluster_parameter_group_format = {
|
||||
'ClusterParameterGroup' => {
|
||||
"ParameterGroupFamily" => String,
|
||||
"Description" => String,
|
||||
"ParameterGroupName" => String
|
||||
}
|
||||
}
|
||||
|
||||
@cluster_parameter_groups_format = {
|
||||
"ParameterGroups"=> [@cluster_parameter_group_format]
|
||||
}
|
||||
|
||||
@modify_cluster_parameter_group_format = {
|
||||
"ParameterGroupStatus" => String,
|
||||
"ParameterGroupName" => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests("create_cluster_parameter_group").formats(@cluster_parameter_group_format) do
|
||||
body = Fog::AWS[:redshift].create_cluster_parameter_group(:parameter_group_name=> parameter_group,
|
||||
:parameter_group_family=>"redshift-1.0",
|
||||
:description=>'testing').body
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("describe_cluster_parameter_groups").formats(@cluster_parameter_groups_format) do
|
||||
body = Fog::AWS[:redshift].describe_cluster_parameter_groups.body
|
||||
body
|
||||
end
|
||||
|
||||
tests("describe_cluster_parameters").formats(@cluster_parameters_format) do
|
||||
body = Fog::AWS[:redshift].describe_cluster_parameters(:parameter_group_name=>parameter_group).body
|
||||
body
|
||||
end
|
||||
|
||||
tests("modify_cluster_parameter_groups").formats(@modify_cluster_parameter_group_format) do
|
||||
body = Fog::AWS[:redshift].modify_cluster_parameter_group(:parameter_group_name=>parameter_group,
|
||||
:parameters=>{
|
||||
:parameter_name=>'extra_float_digits',
|
||||
:parameter_value=>2}).body
|
||||
body
|
||||
end
|
||||
|
||||
tests("delete_cluster_parameter_group") do
|
||||
present = !Fog::AWS[:redshift].describe_cluster_parameter_groups(:parameter_group_name=>parameter_group).body['ParameterGroups'].empty?
|
||||
tests("verify presence before deletion").returns(true) { present }
|
||||
|
||||
Fog::AWS[:redshift].delete_cluster_parameter_group(:parameter_group_name=>parameter_group)
|
||||
|
||||
not_present = Fog::AWS[:redshift].describe_cluster_parameter_groups(:parameter_group_name=>parameter_group).body['ParameterGroups'].empty?
|
||||
tests("verify deletion").returns(true) { not_present }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
44
tests/aws/requests/redshift/cluster_security_group_tests.rb
Normal file
44
tests/aws/requests/redshift/cluster_security_group_tests.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
Shindo.tests('Fog::Redshift[:aws] | cluster security group requests', ['aws']) do
|
||||
|
||||
suffix = rand(65536).to_s(16)
|
||||
identifier = "test-cluster-security-group-#{suffix}"
|
||||
|
||||
@cluster_security_group_format = {
|
||||
"ClusterSecurityGroup" => {
|
||||
"EC2SecurityGroups" => Fog::Nullable::Array,
|
||||
"IPRanges" => Fog::Nullable::Array,
|
||||
"Description" => String,
|
||||
"ClusterSecurityGroupName" => String
|
||||
}
|
||||
}
|
||||
|
||||
@describe_cluster_security_groups_format = {
|
||||
"ClusterSecurityGroups" => [@cluster_security_group_format]
|
||||
}
|
||||
|
||||
|
||||
tests('success') do
|
||||
tests("create_cluster_security_group").formats(@cluster_security_group_format) do
|
||||
body = Fog::AWS[:redshift].create_cluster_security_group(:cluster_security_group_name => identifier, :description => 'testing').body
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("describe_cluster_security_groups").formats(@describe_cluster_security_groups_format) do
|
||||
body = Fog::AWS[:redshift].describe_cluster_security_groups.body
|
||||
body
|
||||
end
|
||||
|
||||
tests("delete_cluster_security_group") do
|
||||
present = !Fog::AWS[:redshift].describe_cluster_security_groups(:cluster_security_group_name => identifier).body['ClusterSecurityGroups'].empty?
|
||||
tests("verify presence before deletion").returns(true) { present }
|
||||
|
||||
Fog::AWS[:redshift].delete_cluster_security_group(:cluster_security_group_name => identifier)
|
||||
|
||||
not_present = Fog::AWS[:redshift].describe_cluster_security_groups(:cluster_security_group_name => identifier).body['ClusterSecurityGroups'].empty?
|
||||
tests("verify deletion").returns(true) { not_present }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
75
tests/aws/requests/redshift/cluster_snapshot_tests.rb
Normal file
75
tests/aws/requests/redshift/cluster_snapshot_tests.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
Shindo.tests('Fog::Redshift[:aws] | cluster snapshot requests', ['aws']) do
|
||||
|
||||
suffix = rand(65536).to_s(16)
|
||||
identifier = "test-snapshot-#{suffix}"
|
||||
cluster = "test-cluster-#{suffix}"
|
||||
start_time = Fog::Time.now.to_iso8601_basic
|
||||
@cluster_snapshot_format = {
|
||||
'Snapshot' => {
|
||||
"AccountsWithRestoreAccess" => Fog::Nullable::Array,
|
||||
"Port" => Integer,
|
||||
"SnapshotIdentifier" => String,
|
||||
"OwnerAccount" => String,
|
||||
"Status" => String,
|
||||
"SnapshotType" => String,
|
||||
"ClusterVersion" => String,
|
||||
"EstimatedSecondsToCompletion" => Integer,
|
||||
"SnapshotCreateTime" => Time,
|
||||
"Encrypted" => Fog::Boolean,
|
||||
"NumberOfNodes" => Integer,
|
||||
"DBName" => String,
|
||||
"CurrentBackupRateInMegaBytesPerSecond" => Float,
|
||||
"ClusterCreateTime" => Time,
|
||||
"AvailabilityZone" => String,
|
||||
"ActualIncrementalBackupSizeInMegaBytes" => Float,
|
||||
"TotalBackupSizeInMegaBytes" => Float,
|
||||
"ElapsedTimeInSeconds" => Integer,
|
||||
"BackupProgressInMegaBytes" => Float,
|
||||
"NodeType" => String,
|
||||
"ClusterIdentifier" => String,
|
||||
"MasterUsername" => String
|
||||
}
|
||||
}
|
||||
|
||||
@describe_cluster_snapshots_format = {
|
||||
"Snapshots" => [@cluster_snapshot_format]
|
||||
}
|
||||
|
||||
|
||||
tests('success') do
|
||||
tests("create_cluster_snapshot").formats(@cluster_snapshot_format) do
|
||||
Fog::AWS[:redshift].create_cluster(:cluster_identifier => cluster,
|
||||
:master_user_password => 'Pass1234',
|
||||
:master_username => 'testuser',
|
||||
:node_type => 'dw.hs1.xlarge',
|
||||
:cluster_type => 'single-node')
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>cluster).body['ClusterSet'].first['Cluster']['ClusterStatus']
|
||||
end
|
||||
body = Fog::AWS[:redshift].create_cluster_snapshot(:snapshot_identifier => identifier,
|
||||
:cluster_identifier => cluster).body
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests('describe_cluster_snaphots').formats(@describe_cluster_snapshots_format) do
|
||||
sleep 30 unless Fog.mocking?
|
||||
body = Fog::AWS[:redshift].describe_cluster_snapshots(:start_time=>start_time).body
|
||||
body
|
||||
end
|
||||
|
||||
tests('delete_cluster_snapshot').formats(@cluster_snapshot_format) do
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_cluster_snapshots(:snapshot_identifier=>identifier).body['Snapshots'].first['Snapshot']['Status']
|
||||
end
|
||||
sleep 30 unless Fog.mocking?
|
||||
body = Fog::AWS[:redshift].delete_cluster_snapshot(:snapshot_identifier=>identifier).body
|
||||
body
|
||||
end
|
||||
|
||||
Fog::AWS[:redshift].delete_cluster(:cluster_identifier => cluster,
|
||||
:skip_final_cluster_snapshot => true)
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -2,81 +2,81 @@ Shindo.tests('Fog::Redshift[:aws] | cluster requests', ['aws']) do
|
|||
|
||||
identifier = "test-cluster-#{rand(65536).to_s(16)}"
|
||||
|
||||
@cluster_format = {
|
||||
"ClusterParameterGroups" => [{
|
||||
"ParameterApplyStatus" => String,
|
||||
"ParameterGroupName" => String
|
||||
}],
|
||||
"ClusterSecurityGroups" => [{
|
||||
"Status" => String,
|
||||
"ClusterSecurityGroupName" => String
|
||||
}],
|
||||
"VpcSecurityGroups" => Fog::Nullable::Array,
|
||||
"EndPoint" => Fog::Nullable::Hash,
|
||||
"PendingModifiedValues" => Fog::Nullable::Hash, #{"MasterUserPassword" => String},
|
||||
"RestoreStatus" => Fog::Nullable::Hash,
|
||||
"ClusterVersion" => String,
|
||||
"ClusterStatus" => String,
|
||||
"Encrypted" => Fog::Boolean,
|
||||
"NumberOfNodes" => Integer,
|
||||
"PubliclyAccessible" => Fog::Boolean,
|
||||
"AutomatedSnapshotRetentionPeriod" => Integer,
|
||||
"DBName" => String,
|
||||
"PreferredMaintenanceWindow" => String,
|
||||
"NodeType" => String,
|
||||
"ClusterIdentifier" => String,
|
||||
"AllowVersionUpgrade" => Fog::Boolean,
|
||||
"MasterUsername" => String
|
||||
@cluster_format = {
|
||||
'Cluster' => {
|
||||
"ClusterParameterGroups" => [{
|
||||
"ClusterParameterGroup" => {
|
||||
"ParameterApplyStatus" => String,
|
||||
"ParameterGroupName" => String
|
||||
}
|
||||
}],
|
||||
"ClusterSecurityGroups" => [{
|
||||
'ClusterSecurityGroup' => {
|
||||
"Status" => String,
|
||||
"ClusterSecurityGroupName" => String
|
||||
}
|
||||
}],
|
||||
"VpcSecurityGroups" => Fog::Nullable::Array,
|
||||
"EndPoint" => Fog::Nullable::Hash,
|
||||
"PendingModifiedValues" => Fog::Nullable::Hash,
|
||||
"RestoreStatus" => Fog::Nullable::Hash,
|
||||
"ClusterVersion" => String,
|
||||
"ClusterStatus" => String,
|
||||
"Encrypted" => Fog::Boolean,
|
||||
"NumberOfNodes" => Integer,
|
||||
"PubliclyAccessible" => Fog::Boolean,
|
||||
"AutomatedSnapshotRetentionPeriod" => Integer,
|
||||
"DBName" => String,
|
||||
"PreferredMaintenanceWindow" => String,
|
||||
"NodeType" => String,
|
||||
"ClusterIdentifier" => String,
|
||||
"AllowVersionUpgrade" => Fog::Boolean,
|
||||
"MasterUsername" => String
|
||||
}
|
||||
}
|
||||
|
||||
@describe_clusters_format = {
|
||||
"ClusterSet" => [
|
||||
@cluster_format.merge({"ClusterCreateTime"=>Time, "AvailabilityZone"=>String, "EndPoint"=>{"Port"=>Integer, "Address"=>String}})
|
||||
]
|
||||
"ClusterSet" => [{
|
||||
'Cluster' => @cluster_format['Cluster'].merge({"ClusterCreateTime"=>Time, "AvailabilityZone"=>String, "EndPoint"=>{"Port"=>Integer, "Address"=>String}})
|
||||
}]
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests("create_cluster").formats(@cluster_format) do
|
||||
tests('create_cluster').formats(@cluster_format) do
|
||||
body = Fog::AWS[:redshift].create_cluster(:cluster_identifier => identifier,
|
||||
:master_user_password => 'Password1234',
|
||||
:master_username => 'testuser',
|
||||
:node_type => 'dw.hs1.xlarge',
|
||||
:cluster_type => 'single-node').body
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['Cluster']['ClusterStatus']
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#describe_clusters").formats(@describe_clusters_format["ClusterSet"]) do
|
||||
tests('describe_clusters').formats(@describe_clusters_format["ClusterSet"]) do
|
||||
sleep 30 unless Fog.mocking?
|
||||
body = Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body["ClusterSet"]
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#reboot_cluster") do
|
||||
sleep 30
|
||||
tests('reboot_cluster') do
|
||||
sleep 30 unless Fog.mocking?
|
||||
body = Fog::AWS[:redshift].reboot_cluster(:cluster_identifier=>identifier).body
|
||||
tests("verify reboot").returns("rebooting") { body['ClusterStatus']}
|
||||
tests("verify reboot").returns("rebooting") { body['Cluster']['ClusterStatus']}
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests('delete_cluster') do
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['Cluster']['ClusterStatus']
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#delete_cluster") do
|
||||
sleep 30
|
||||
sleep 30 unless Fog.mocking?
|
||||
body = Fog::AWS[:redshift].delete_cluster(:cluster_identifier=>identifier, :skip_final_cluster_snapshot=>true).body
|
||||
tests("verify delete").returns("deleting") { body['ClusterStatus']}
|
||||
tests("verify delete").returns("deleting") { body['Cluster']['ClusterStatus']}
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# tests('failure') do
|
||||
# end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue