示例#1
0
    def Run(self, args):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())
        response = client.List(args.ip)

        rules = list(response)
        if rules:
            log.status.Print(
                'The action `{0}` will apply to the IP address.\n'.format(
                    rules[0].action))
            log.status.Print('Matching Rules')
        else:
            log.status.Print('No rules match the IP address.')

        return rules
示例#2
0
    def Run(self, args):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())
        priority = firewall_rules_util.ParsePriority(args.priority)
        resource = firewall_rules_util.ParseFirewallRule(client, priority)
        action = firewall_rules_util.ParseAction(client.messages, args.action)

        try:
            rule = client.Update(resource, priority, args.source_range, action,
                                 args.description)
        except util.NoFieldsSpecifiedError:
            firewall_rules_util.RaiseMinArgument()

        log.UpdatedResource(priority)
        return rule
示例#3
0
    def Run(self, args):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())
        priority = firewall_rules_util.ParsePriority(args.priority)

        if priority == firewall_rules_util.DEFAULT_RULE_PRIORITY:
            raise exceptions.InvalidArgumentException(
                'priority', 'The `default` can not be created, only updated.')

        action = firewall_rules_util.ParseAction(client.messages, args.action)

        rule = client.Create(priority, args.source_range, action,
                             args.description)
        log.CreatedResource(args.priority)
        return rule
示例#4
0
  def Run(self, args):
    priority = firewall_rules_util.ParsePriority(args.priority)
    if priority == firewall_rules_util.DEFAULT_RULE_PRIORITY:
      raise exceptions.InvalidArgumentException(
          'priority', 'The `default` can not be deleted, only updated.')

    console_io.PromptContinue(
        prompt_string='You are about to delete rule [{0}].'.format(priority),
        cancel_on_no=True)

    client = api_client.GetApiClientForTrack(self.ReleaseTrack())
    resource = firewall_rules_util.ParseFirewallRule(client, priority)
    client.Delete(resource)

    log.DeletedResource(priority)
示例#5
0
    def Run(self, args):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())
        resource = firewall_rules_util.ParseFirewallRule(client, args.priority)

        return client.Get(resource)
示例#6
0
 def Run(self, args):
     client = api_client.GetApiClientForTrack(self.ReleaseTrack())
     return client.List()