diff --git a/lib/fog/aws/parsers/redshift/create_cluster_parameter_group.rb b/lib/fog/aws/parsers/redshift/create_cluster_parameter_group.rb new file mode 100644 index 000000000..b3186cd53 --- /dev/null +++ b/lib/fog/aws/parsers/redshift/create_cluster_parameter_group.rb @@ -0,0 +1,30 @@ +module Fog + module Parsers + module Redshift + module AWS + + class CreateClusterParameterGroup < Fog::Parsers::Base + # :parameter_group_name - (String) + # :parameter_group_family - (String) + # :description - (String) + + def reset + @response = {} + end + + def start_element(name, attrs = []) + super + end + + def end_element(name) + super + case name + when 'ParameterGroupName', 'ParameterGroupFamily', 'Description' + @response[name] = value + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/parsers/redshift/create_cluster_security_group.rb b/lib/fog/aws/parsers/redshift/create_cluster_security_group.rb new file mode 100644 index 000000000..313275913 --- /dev/null +++ b/lib/fog/aws/parsers/redshift/create_cluster_security_group.rb @@ -0,0 +1,31 @@ +module Fog + module Parsers + module Redshift + module AWS + + require 'fog/aws/parsers/redshift/cluster_security_group_parser' + + class CreateClusterSecurityGroup < 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 \ No newline at end of file diff --git a/lib/fog/aws/parsers/redshift/create_cluster_subnet_group.rb b/lib/fog/aws/parsers/redshift/create_cluster_subnet_group.rb new file mode 100644 index 000000000..7d6e3ef20 --- /dev/null +++ b/lib/fog/aws/parsers/redshift/create_cluster_subnet_group.rb @@ -0,0 +1,51 @@ +module Fog + module Parsers + module Redshift + module AWS + + class ClusterSubnetGroupParser < Fog::Parsers::Base + # :cluster_subnet_group_name - (String) + # :description - (String) + # :vpc_id - (String) + # :subnet_group_status - (String) + # :subnets - (Array) + # :subnet_identifier - (String) + # :subnet_availability_zone - (Hash) + # :name - (String) + # :subnet_status - (String) + + def reset + @response = { 'Subnets' => [] } + end + + def fresh_subnet + {'SubnetAvailabilityZone'=>{}} + end + + def start_element(name, attrs = []) + super + case name + when 'Subnets' + @subnet = fresh_subnet + end + end + + def end_element(name) + super + case name + when 'ClusterSubnetGroupName', 'Desciption', 'VpcId', 'SubnetGroupStatus' + @response[name] = value + when 'SubnetIdentifier', 'SubnetStatus' + @subnet[name] = value + when 'Name' + @subnet['SubnetAvailabilityZone'][name] = value + when 'Subnet' + @response['Subnets'] << @subnet + @subnet = fresh_subnet + end + end + end + end + end + end +end diff --git a/lib/fog/aws/redshift.rb b/lib/fog/aws/redshift.rb index 3ddfc11f1..877cbe9d2 100644 --- a/lib/fog/aws/redshift.rb +++ b/lib/fog/aws/redshift.rb @@ -23,11 +23,11 @@ module Fog request :describe_reserved_node_offerings request :describe_reserved_nodes request :describe_resize - # request :create_cluster - # request :create_cluster_parameter_group - # request :create_cluster_security_group - # request :create_cluster_snapshot - # request :create_cluster_subnet_group + request :create_cluster + request :create_cluster_parameter_group + request :create_cluster_security_group + request :create_cluster_snapshot + request :create_cluster_subnet_group # request :modify_cluster # request :modify_cluster_parameter_group # request :modify_cluster_subnet_group diff --git a/lib/fog/aws/requests/redshift/create_cluster.rb b/lib/fog/aws/requests/redshift/create_cluster.rb new file mode 100644 index 000000000..58d57b913 --- /dev/null +++ b/lib/fog/aws/requests/redshift/create_cluster.rb @@ -0,0 +1,151 @@ +module Fog + module AWS + class Redshift + class Real + require 'fog/aws/parsers/redshift/cluster_parser' + + # ==== Parameters + # + # @param [Hash] options + # * :db_name - (String) + # The name of the first database to be created when the cluster is created. To create + # additional databases after the cluster is created, connect to the cluster with a SQL + # client and use SQL commands to create a database. Default: dev Constraints: Must + # contain 1 to 64 alphanumeric characters. Must contain only lowercase letters. + # * :cluster_identifier - required - (String) + # A unique identifier for the cluster. You use this identifier to refer to the cluster + # for any subsequent cluster operations such as deleting or modifying. Must be unique + # for all clusters within an AWS account. Example: myexamplecluster + # * :cluster_type - (String) + # Type of the cluster. When cluster type is specified as single-node, the NumberOfNodes + # parameter is not required. multi-node, the NumberOfNodes parameter is required. Valid + # Values: multi-node | single-node Default: multi-node + # * :node_type - required - (String) + # The node type to be provisioned. Valid Values: dw.hs1.xlarge | dw.hs1.8xlarge. + # * :master_username - required - (String) + # The user name associated with the master user account for the cluster that is being + # created. Constraints: Must be 1 - 128 alphanumeric characters. First character must + # be a letter. Cannot be a reserved word. + # * :master_user_password - required - (String) + # The password associated with the master user account for the cluster that is being + # created. Constraints: Must be between 8 and 64 characters in length. Must contain at + # least one uppercase letter. Must contain at least one lowercase letter. Must contain + # one number. + # * :cluster_security_groups - (Array) + # A list of security groups to be associated with this cluster. Default: The default + # cluster security group for Amazon Redshift. + # * :vpc_security_group_ids - (Array) + # A list of Virtual Private Cloud (VPC) security groups to be associated with the + # cluster. Default: The default VPC security group is associated with the cluster. + # * :cluster_subnet_group_name - (String) + # The name of a cluster subnet group to be associated with this cluster. If this + # parameter is not provided the resulting cluster will be deployed outside virtual + # private cloud (VPC). + # * :availability_zone - (String) + # The EC2 Availability Zone (AZ) in which you want Amazon Redshift to provision the + # cluster. Default: A random, system-chosen Availability Zone in the region that is + # specified by the endpoint. Example: us-east-1d Constraint: The specified + # Availability Zone must be in the same region as the current endpoint. + # * :preferred_maintenance_window - (String) + # The weekly time range (in UTC) during which automated cluster maintenance can occur. + # Format: ddd:hh24:mi-ddd:hh24:mi Default: A 30-minute window selected at random from + # an 8-hour block of time per region, occurring on a random day of the week. + # Constraints: Minimum 30-minute window. + # * :cluster_parameter_group_name - (String) + # The name of the parameter group to be associated with this cluster. Default: The + # default Amazon Redshift cluster parameter group. Constraints: Must be 1 to 255 + # alphanumeric characters or hyphens. First character must be a letter. Cannot end + # with a hyphen or contain two consecutive hyphens. + # * :automated_snapshot_retention_period - (Integer) + # Number of days that automated snapshots are retained. If the value is 0, automated + # snapshots are disabled. Default: 1 Constraints: Must be a value from 0 to 35. + # * :port - (Integer) + # The port number on which the cluster accepts incoming connections. Default: 5439 + # Valid Values: 1150-65535 + # * :cluster_version - (String) + # The version of the Amazon Redshift engine software that you want to deploy on the + # cluster. The version selected runs on all the nodes in the cluster. Constraints: + # Only version 1.0 is currently available. Example: 1.0 + # * :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` + # * :number_of_nodes - (Integer) + # The number of compute nodes in the cluster. This parameter is required when the + # ClusterType parameter is specified as multi-node. If you don't specify this parameter, + # you get a single-node cluster. When requesting a multi-node cluster, you must specify + # the number of nodes that you want in the cluster. Default: 1 Constraints: Value must + # be at least 1 and no more than 100. + # * :publicly_accessible - (Boolean) + # If `true` , the cluster can be accessed from a public network. + # * :encrypted - (Boolean) + # If `true` , the data in cluster is encrypted at rest. Default: `false` + + # ==== See Also + # http://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateCluster.html + def create_cluster(options = {}) + db_name = options[:db_name] + cluster_identifier = options[:cluster_identifier] + cluster_type = options[:cluster_type] + node_type = options[:node_type] + master_username = options[:master_username] + master_user_password = options[:master_user_password] + cluster_subnet_group_name = options[:cluster_subnet_group_name] + availability_zone = options[:availability_zone] + preferred_maintenance_window = options[:preferred_maintenance_window] + cluster_parameter_group_name = options[:cluster_parameter_group_name] + automated_snapshot_retention_period = options[:automated_snapshot_retention_period] + port = options[:port] + cluster_version = options[:cluster_version] + allow_version_upgrade = options[:allow_version_upgrade] + number_of_nodes = options[:number_of_nodes] + publicly_accessible = options[:publicly_accessible] + encrypted = options[:encrypted] + + path = "/" + params = { + :idempotent => true, + :headers => {}, + :path => path, + :method => :put, + :query => {}, + :parser => Fog::Parsers::Redshift::AWS::ClusterParser.new + } + + if cluster_security_groups = options.delete(:ClusterSecurityGroups) + params[:query].merge!(Fog::AWS.indexed_param('ClusterSecurityGroups.member.%d', [*cluster_security_groups])) + end + + if vpc_security_group_ids = options.delete(:VpcSecurityGroupIds) + params[:query].merge!(Fog::AWS.indexed_param('VpcSecurityGroupIds.member.%d', [*vpc_security_group_ids])) + end + + + params[:query]['Action'] = 'CreateCluster' + params[:query]['DBName'] = db_name if db_name + params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier + params[:query]['ClusterType'] = cluster_type if cluster_type + params[:query]['NodeType'] = node_type if node_type + params[:query]['MasterUsername'] = master_username if master_username + params[:query]['MasterUserPassword'] = master_user_password if master_user_password + params[:query]['ClusterSecurityGroups'] = cluster_security_groups if cluster_security_groups + params[:query]['VpcSecurityGroupIds'] = vpc_security_group_ids if vpc_security_group_ids + params[:query]['ClusterSubnetGroupName'] = cluster_subnet_group_name if cluster_subnet_group_name + params[:query]['AvailabilityZone'] = availability_zone if availability_zone + params[:query]['PreferredMaintenanceWindow'] = preferred_maintenance_window if preferred_maintenance_window + params[:query]['ClusterParameterGroupName'] = cluster_parameter_group_name if cluster_parameter_group_name + params[:query]['AutomatedSnapshotRetentionPeriod'] = automated_snapshot_retention_period if automated_snapshot_retention_period + params[:query]['Port'] = port if port + params[:query]['ClusterVersion'] = cluster_version if cluster_version + params[:query]['AllowVersionUpgrade'] = allow_version_upgrade if allow_version_upgrade + params[:query]['NumberOfNodes'] = number_of_nodes if number_of_nodes + params[:query]['PubliclyAccessible'] = publicly_accessible if publicly_accessible + params[:query]['Encrypted'] = encrypted if encrypted + + + request(params) + end + end + + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/requests/redshift/create_cluster_parameter_group.rb b/lib/fog/aws/requests/redshift/create_cluster_parameter_group.rb new file mode 100644 index 000000000..2211eeeee --- /dev/null +++ b/lib/fog/aws/requests/redshift/create_cluster_parameter_group.rb @@ -0,0 +1,54 @@ +module Fog + module AWS + class Redshift + class Real + require 'fog/aws/parsers/redshift/create_cluster_parameter_group' + + # ==== Parameters + # + # @param [Hash] options + # * :parameter_group_name - required - (String) + # The name of the cluster parameter group. Constraints: Must be 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 within your AWS account. This value + # is stored as a lower-case string. + # * :parameter_group_family - required - (String) + # The Amazon Redshift engine version to which the cluster parameter group applies. The + # cluster engine version determines the set of parameters. To get a list of valid parameter + # group family names, you can call DescribeClusterParameterGroups. By default, Amazon + # Redshift returns a list of all the parameter groups that are owned by your AWS account, + # including the default parameter groups for each Amazon Redshift engine version. The + # parameter group family names associated with the default parameter groups provide you + # the valid values. For example, a valid family name is "redshift-1.0". + # * :description - required - (String) + # A description of the parameter group. + # + # ==== See Also + # http://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateClusterParameterGroup.html + def create_cluster_parameter_group(options = {}) + parameter_group_name = options[:parameter_group_name] + parameter_group_family = options[:parameter_group_family] + description = options[:description] + + path = "/" + params = { + :idempotent => true, + :headers => {}, + :path => path, + :method => :put, + :query => {}, + :parser => Fog::Parsers::Redshift::AWS::CreateClusterParameterGroup.new + } + + params[:query]['Action'] = 'CreateClusterParameterGroup' + params[:query]['ParameterGroupName'] = parameter_group_name if parameter_group_name + params[:query]['ParameterGroupFamily'] = parameter_group_family if parameter_group_family + params[:query]['Description'] = description if description + + request(params) + end + end + + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/requests/redshift/create_cluster_security_group.rb b/lib/fog/aws/requests/redshift/create_cluster_security_group.rb new file mode 100644 index 000000000..db8cfb9fe --- /dev/null +++ b/lib/fog/aws/requests/redshift/create_cluster_security_group.rb @@ -0,0 +1,42 @@ +module Fog + module AWS + class Redshift + class Real + require 'fog/aws/parsers/redshift/create_cluster_security_group' + + # ==== Parameters + # + # @param [Hash] options + # * :cluster_security_group_name - (String) + # The name of a cluster security group for which you are requesting details. You + # can specify either the Marker parameter or a ClusterSecurityGroupName parameter, + # but not both. Example: securitygroup1 + # * :description - required - (String) + # A description for the security group. + # + # ==== See Also + # http://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateClusterSecurityGroup.html + def create_cluster_security_group(options = {}) + cluster_security_group_name = options[:cluster_security_group_name] + description = options[:description] + + path = "/" + params = { + :headers => {}, + :path => path, + :method => :put, + :query => {}, + :parser => Fog::Parsers::Redshift::AWS::CreateClusterSecurityGroup.new + } + + params[:query]['Action'] = 'CreateClusterSecurityGroup' + params[:query]['ClusterSecurityGroupName'] = cluster_security_group_name if cluster_security_group_name + params[:query]['Description'] = description if description + + request(params) + end + end + + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/requests/redshift/create_cluster_snapshot.rb b/lib/fog/aws/requests/redshift/create_cluster_snapshot.rb new file mode 100644 index 000000000..9ca4134e1 --- /dev/null +++ b/lib/fog/aws/requests/redshift/create_cluster_snapshot.rb @@ -0,0 +1,44 @@ +module Fog + module AWS + class Redshift + class Real + require 'fog/aws/parsers/redshift/cluster_snapshot_parser' + + # ==== Parameters + # + # @param [Hash] options + # * :snapshot_identifier - required - (String) + # A unique identifier for the snapshot that you are requesting. This identifier + # must be unique for all snapshots within the AWS account. 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 Example: my-snapshot-id + # * :cluster_identifier - required - (String) + # The cluster identifier for which you want a snapshot. + # + # ==== See Also + # http://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateClusterSnapshot.html + def create_cluster_snapshot(options = {}) + snapshot_identifier = options[:snapshot_identifier] + cluster_identifier = options[:cluster_identifier] + + path = "/" + params = { + :headers => {}, + :path => path, + :method => :put, + :query => {}, + :parser => Fog::Parsers::Redshift::AWS::ClusterSnapshotParser.new + } + + params[:query]['Action'] = 'CreateClusterSnapshot' + params[:query]['SnapshotIdentifier'] = snapshot_identifier if snapshot_identifier + params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier + + request(params) + end + end + + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/requests/redshift/create_cluster_subnet_group.rb b/lib/fog/aws/requests/redshift/create_cluster_subnet_group.rb new file mode 100644 index 000000000..02e952691 --- /dev/null +++ b/lib/fog/aws/requests/redshift/create_cluster_subnet_group.rb @@ -0,0 +1,50 @@ +module Fog + module AWS + class Redshift + class Real + require 'fog/aws/parsers/redshift/cluster_subnet_group_parser' + + # ==== Parameters + # + # @param [Hash] options + # * :cluster_subnet_group_name - required - (String) + # The name for the subnet group. Amazon Redshift stores the value as a lowercase string. + # Constraints: Must contain no more than 255 alphanumeric characters or hyphens. Must not + # be "Default". Must be unique for all subnet groups that are created by your AWS account. + # Example: examplesubnetgroup + # * :description - required - (String) + # A description of the parameter group. + # * :subnet_ids - required - (Array<) + # An array of VPC subnet IDs. A maximum of 20 subnets can be modified in a single request. + # + # ==== See Also + # http://docs.aws.amazon.com/redshift/latest/APIReference/API_CreateClusterSubnetGroup.html + def create_cluster_subnet_group(options = {}) + cluster_subnet_group_name = options[:cluster_subnet_group_name] + description = options[:description] + + path = "/" + params = { + :idempotent => true, + :headers => {}, + :path => path, + :method => :put, + :query => {}, + :parser => Fog::Parsers::Redshift::AWS::ClusterSubnetGroupParser.new + } + + if subnet_ids = options.delete(:subnet_ids) + params[:query].merge!(Fog::AWS.indexed_param('SubnetIds.member.%d', [*subnet_ids])) + end + + params[:query]['Action'] = 'CreateClusterSubnetGroup' + params[:query]['ClusterSubnetGroupName'] = cluster_subnet_group_name if cluster_subnet_group_name + params[:query]['Description'] = description if description + + request(params) + end + end + + end + end +end \ No newline at end of file