If is_create is True, protocol and action become mandatory arguments.

    CreateCommand = is_create : True
    UpdateCommand = is_create : False
963296
def _add_common_args(parser, is_create=True):
    
    parser.add_argument(
        '--name',
        help=_('Name for the firewall rule.'))
    parser.add_argument(
        '--description',
        help=_('Description for the firewall rule.'))
    parser.add_argument(
        '--source-ip-address',
        help=_('Source IP address or subnet.'))
    parser.add_argument(
        '--destination-ip-address',
        help=_('Destination IP address or subnet.'))
    parser.add_argument(
        '--source-port',
        help=_('Source port (integer in [1, 65535] or range in a:b).'))
    parser.add_argument(
        '--destination-port',
        help=_('Destination port (integer in [1, 65535] or range in '
               'a:b).'))
    utils.add_boolean_argument(
        parser, '--enabled', dest='enabled',
        help=_('Whether to enable or disable this rule.'))
    parser.add_argument(
        '--protocol', choices=['tcp', 'udp', 'icmp', 'any'],
        required=is_create,
        type=utils.convert_to_lowercase,
        help=_('Protocol for the firewall rule.'))
    parser.add_argument(
        '--action',
        required=is_create,
        type=utils.convert_to_lowercase,
        choices=['allow', 'deny', 'reject'],
        help=_('Action for the firewall rule.'))
672268
def _update(self, **kwargs):
        
        if 'value' in kwargs and self.protocol_agent_values.get('value') != \
            kwargs.get('value'):
            self.protocol_agent_values.update(value=kwargs['value'])
            return True
        return False
237287
def _check_create_parameters(self, **kwargs):
        
        rset = self._meta_data['required_creation_parameters']
        check = _missing_required_parameters(rset, **kwargs)
        if check:
            error_message = 'Missing required params: %s' % check
            raise MissingRequiredCreationParameter(error_message)
1134094
def update(cls, **kwargs):
        '''
        
        '''
        q = cls._get_instance(**{'id': kwargs['id']})
        if q:
            for k, v in kwargs.items():
                setattr(q, k, v)
            _action_and_commit(q, session.add)
        else:
            cls.get_or_create(**kwargs)
735525
def get_or_create(self, **kwargs):
        
        assert kwargs, "get_or_create() must be passed at least one keyword argument"

        defaults = kwargs.pop("defaults", {})
        lookup = kwargs.copy()

        try:
            return self.get(**lookup), False
        except self.resource.DoesNotExist:
            params = dict([(k, v) for k, v in kwargs.items()])
            params.update(defaults)

            obj = self.create(**params)
            return obj, True
1085037
protected ActionCommand createUpdateCommand()
    {
        ActionCommand command = new ActionCommand(UPDATE_COMMAND_ID)
        {

            @Override
            protected void doExecuteCommand()
            {
                doUpdate();
            }
        };
        command.setSecurityControllerId(getId() + "." + UPDATE_COMMAND_ID);
        getApplicationConfig().commandConfigurer().configure(command);
        getDetailForm().addGuarded(command, FormGuard.LIKE_COMMITCOMMAND);
        return command;
    }
39080
def create_with_validation(cls, *args, **kwargs):
        
        ret_val = cls(*args, **kwargs)
        ret_val.full_clean()
        ret_val.save()
        return ret_val
84331
def get_or_create(self, request, *args, **kwargs):
        """"""
        kwargs['get_or_create'] = True
        return self.create(request, *args, **kwargs)
95598
def create_event(*args)
      raise "EventCampaign needs to be saved before Event creation" if self.id.nil?

      (args[0]).merge!(:campaign_id => self.id)

      event = ActionKitApi::Event.new(*args)
    end
1105576
def is_required(action):
  ''' '''
  return not action.option_strings and not isinstance(action, _SubParsersAction) or action.required == True
782628
def __create(self, options, collation, session):
        
        cmd = SON([("create", self.__name)])
        if options:
            if "size" in options:
                options["size"] = float(options["size"])
            cmd.update(options)
        with self._socket_for_writes(session) as sock_info:
            self._command(
                sock_info, cmd, read_preference=ReadPreference.PRIMARY,
                write_concern=self._write_concern_for(session),
                collation=collation, session=session)
1036253
def _add_boolean_cli_param(params, key, value):
    '''
    
    '''
    if value is True:
        params.append('--{0}'.format(key))
489139
def call
      if arguments.valid?
        Qiita::Commands::Request.new(arguments)
      else
        Qiita::Commands::Error.new(arguments)
      end
    end
76234
def allow(cls, action, **kwargs):
        
        return cls.create(action, exclude=False, **kwargs)
271768
def save(self, must_create=False):
        
        obj = Session(
            session_key=self._get_or_create_session_key(),
            session_data=self.encode(self._get_session(no_load=must_create)),
            expire_date=self.get_expiry_date(),
            user_agent=self.user_agent,
            user_id=self.user_id,
            ip=self.ip,
        )
        using = router.db_for_write(Session, instance=obj)
        try:
            with transaction.atomic(using):
                obj.save(force_insert=must_create, using=using)
        except IntegrityError as e:
            if must_create and 'session_key' in str(e):
                raise CreateError
            raise
2139
def set_or_create(self, path, *args, **kwargs):
        """"""

        d = self.set(path, *args, **kwargs)

        @d.addErrback
        def _error(result):
            return self.create(path, *args, **kwargs)

        return d
999754
def domain_create(args)
      raise ArgumentError, "You can't create a domain with ns records, you must do an update afterwards" if args.key?(:ns)
      raise ArgumentError, "You can't create a domain with ds or key records, you must do an update afterwards" if args.key?(:dsData) || args.key?(:keyData)
      super
    end