Sha256: 8930c83b85c19cb741cbeaafe772ebe4adde8707775e4593092c72531f47c0f1

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        require 'fog/aws/parsers/ec2/basic'

        # 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

14 entries across 14 versions & 1 rubygems

Version Path
fog-0.0.72 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.71 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.70 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.69 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.68 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.67 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.66 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.65 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.64 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.63 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.62 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.61 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.60 lib/fog/aws/requests/ec2/create_security_group.rb
fog-0.0.59 lib/fog/aws/requests/ec2/create_security_group.rb