<commit_before>module Fog
  module AWS
    class EC2

      class SecurityGroup < Fog::Model

        identity  :name,            'groupName'

        attribute :description,     'groupDescription'
        attribute :ip_permissions,  'ipPermissions'
        attribute :owner_id,        'ownerId'

        def authorize_group_and_owner(group, owner)
          requires :name

          connection.authorize_security_group_ingress(
            'GroupName'                   => @name,
            'SourceSecurityGroupName'     => group,
            'SourceSecurityGroupOwnerId'  => owner
          )
        end

        def authorize_port_range(range, options = {})
          requires :name

          connection.authorize_security_group_ingress(
            'CidrIp'      => options[:cidr_ip] || '0.0.0.0/0',
            'FromPort'    => range.min,
            'GroupName'   => @name,
            'ToPort'      => range.max,
            'IpProtocol'  => options[:ip_protocol] || 'tcp' 
          )
        end

        def destroy
          requires :name

          connection.delete_security_group(@name)
          true
        end

        def save
          requires :name

          data = connection.create_security_group(@name, @description).body
          true
        end

      end

    end
  end
end
<commit_msg>description is required for new security groups<commit_after>module Fog
  module AWS
    class EC2

      class SecurityGroup < Fog::Model

        identity  :name,            'groupName'

        attribute :description,     'groupDescription'
        attribute :ip_permissions,  'ipPermissions'
        attribute :owner_id,        'ownerId'

        def authorize_group_and_owner(group, owner)
          requires :name

          connection.authorize_security_group_ingress(
            'GroupName'                   => @name,
            'SourceSecurityGroupName'     => group,
            'SourceSecurityGroupOwnerId'  => owner
          )
        end

        def authorize_port_range(range, options = {})
          requires :name

          connection.authorize_security_group_ingress(
            'CidrIp'      => options[:cidr_ip] || '0.0.0.0/0',
            'FromPort'    => range.min,
            'GroupName'   => @name,
            'ToPort'      => range.max,
            'IpProtocol'  => options[:ip_protocol] || 'tcp' 
          )
        end

        def destroy
          requires :name

          connection.delete_security_group(@name)
          true
        end

        def save
          requires :description, :name

          data = connection.create_security_group(@name, @description).body
          true
        end

      end

    end
  end
end

{'fraction_non_alphanumeric': 0.08469539375928678, 'fraction_numerical': 0.004457652303120356, 'mean_word_length': 1.6044487427466152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6527336', 'n_tokens_mistral': 734, 'n_tokens_neox': 705, 'n_words': 153}