Sha256: 4547dbce9b284c87cc121f13246a0b3ffab908008a14b7521e87bd26c1e92816

Contents?: true

Size: 1.51 KB

Versions: 31

Compression:

Stored size: 1.51 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        # Create a new security group
        #
        # ==== Parameters
        # * group_name<~String> - Name of the security group.
        # * group_description<~String> - Description of group.
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'return'<~Boolean> - success?
        def create_security_group(name, description)
          request(
            'Action'            => 'CreateSecurityGroup',
            'GroupName'         => name,
            'GroupDescription'  => CGI.escape(description),
            :parser             => Fog::Parsers::AWS::EC2::Basic.new
          )
        end

      end

      class Mock

        def create_security_group(name, description)
          response = Excon::Response.new
          unless @data[:security_groups][name]
            data = {
              'groupDescription'  => description,
              'groupName'         => name,
              'ipPermissions'     => [],
              'ownerId'           => @owner_id
            }
            @data[:security_groups][name] = data
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'return'    => true
            }
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
fog-0.1.2 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.1.1 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.1.0 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.100 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.99 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.98 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.97 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.96 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.95 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.94 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.93 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.92 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.91 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.90 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.89 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.88 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.87 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.86 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.85 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.84 lib/fog/aws/requests/ec2/create_security_group.rb