Sha256: 10d6f543065eb4c8c30102ace0c3523d3829416087779d10d9792d259a2c2882

Contents?: true

Size: 1.73 KB

Versions: 7

Compression:

Stored size: 1.73 KB

Contents

module Fog
  module Compute
    class AWS
      class Real

        require 'fog/compute/parsers/aws/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?
        #
        # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html]
        def create_security_group(name, description)
          request(
            'Action'            => 'CreateSecurityGroup',
            'GroupName'         => name,
            'GroupDescription'  => description,
            :parser             => Fog::Parsers::Compute::AWS::Basic.new
          )
        end

      end

      class Mock

        def create_security_group(name, description)
          response = Excon::Response.new
          unless self.data[:security_groups][name]
            data = {
              'groupDescription'  => description,
              'groupName'         => name,
              'ipPermissions'     => [],
              'ownerId'           => self.data[:owner_id]
            }
            self.data[:security_groups][name] = data
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'return'    => true
            }
            response
          else
            raise Fog::Compute::AWS::Error.new("InvalidGroup.Duplicate => The security group '#{name}' already exists")
          end
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/compute/requests/aws/create_security_group.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/compute/requests/aws/create_security_group.rb
fog-0.11.0 lib/fog/compute/requests/aws/create_security_group.rb
fog-0.10.0 lib/fog/compute/requests/aws/create_security_group.rb
fog4encbs-0.9.0.1 lib/fog/compute/requests/aws/create_security_group.rb
fog4encbs-0.9.0 lib/fog/compute/requests/aws/create_security_group.rb
fog-0.9.0 lib/fog/compute/requests/aws/create_security_group.rb