def list(self, project, service_account_file=""):
        stub = firewall_pb2_grpc.ComputeFirewallServiceStub(channel.Channel())
        request = firewall_pb2.ListComputeFirewallRequest()
        request.service_account_file = service_account_file
        request.Project = project

        return stub.ListComputeFirewall(request).items
    def hcl(self):
        stub = firewall_pb2_grpc.ComputeFirewallServiceStub(channel.Channel())
        request = firewall_pb2.ComputeFirewallAsHclRequest()
        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if FirewallDirectionEnum.to_proto(self.direction):
            request.resource.direction = FirewallDirectionEnum.to_proto(
                self.direction)

        if Primitive.to_proto(self.disabled):
            request.resource.disabled = Primitive.to_proto(self.disabled)

        if Primitive.to_proto(self.id):
            request.resource.id = Primitive.to_proto(self.id)

        if FirewallLogConfig.to_proto(self.log_config):
            request.resource.log_config.CopyFrom(
                FirewallLogConfig.to_proto(self.log_config))
        else:
            request.resource.ClearField("log_config")
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.network):
            request.resource.network = Primitive.to_proto(self.network)

        if Primitive.to_proto(self.priority):
            request.resource.priority = Primitive.to_proto(self.priority)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if FirewallAllowedArray.to_proto(self.allowed):
            request.resource.allowed.extend(
                FirewallAllowedArray.to_proto(self.allowed))
        if FirewallDeniedArray.to_proto(self.denied):
            request.resource.denied.extend(
                FirewallDeniedArray.to_proto(self.denied))
        if Primitive.to_proto(self.destination_ranges):
            request.resource.destination_ranges.extend(
                Primitive.to_proto(self.destination_ranges))
        if Primitive.to_proto(self.source_ranges):
            request.resource.source_ranges.extend(
                Primitive.to_proto(self.source_ranges))
        if Primitive.to_proto(self.source_service_accounts):
            request.resource.source_service_accounts.extend(
                Primitive.to_proto(self.source_service_accounts))
        if Primitive.to_proto(self.source_tags):
            request.resource.source_tags.extend(
                Primitive.to_proto(self.source_tags))
        if Primitive.to_proto(self.target_service_accounts):
            request.resource.target_service_accounts.extend(
                Primitive.to_proto(self.target_service_accounts))
        if Primitive.to_proto(self.target_tags):
            request.resource.target_tags.extend(
                Primitive.to_proto(self.target_tags))

        response = stub.ComputeFirewallAsHcl(request)
        return response.hcl
    def delete(self, project, name, service_account_file=""):
        stub = firewall_pb2_grpc.ComputeFirewallServiceStub(channel.Channel())
        request = firewall_pb2.DeleteComputeFirewallRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Name = name

        response = stub.DeleteComputeFirewall(request)
    def apply(self):
        stub = firewall_pb2_grpc.ComputeFirewallServiceStub(channel.Channel())
        request = firewall_pb2.ApplyComputeFirewallRequest()
        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if FirewallDirectionEnum.to_proto(self.direction):
            request.resource.direction = FirewallDirectionEnum.to_proto(
                self.direction)

        if Primitive.to_proto(self.disabled):
            request.resource.disabled = Primitive.to_proto(self.disabled)

        if Primitive.to_proto(self.id):
            request.resource.id = Primitive.to_proto(self.id)

        if FirewallLogConfig.to_proto(self.log_config):
            request.resource.log_config.CopyFrom(
                FirewallLogConfig.to_proto(self.log_config))
        else:
            request.resource.ClearField("log_config")
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.network):
            request.resource.network = Primitive.to_proto(self.network)

        if Primitive.to_proto(self.priority):
            request.resource.priority = Primitive.to_proto(self.priority)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if FirewallAllowedArray.to_proto(self.allowed):
            request.resource.allowed.extend(
                FirewallAllowedArray.to_proto(self.allowed))
        if FirewallDeniedArray.to_proto(self.denied):
            request.resource.denied.extend(
                FirewallDeniedArray.to_proto(self.denied))
        if Primitive.to_proto(self.destination_ranges):
            request.resource.destination_ranges.extend(
                Primitive.to_proto(self.destination_ranges))
        if Primitive.to_proto(self.source_ranges):
            request.resource.source_ranges.extend(
                Primitive.to_proto(self.source_ranges))
        if Primitive.to_proto(self.source_service_accounts):
            request.resource.source_service_accounts.extend(
                Primitive.to_proto(self.source_service_accounts))
        if Primitive.to_proto(self.source_tags):
            request.resource.source_tags.extend(
                Primitive.to_proto(self.source_tags))
        if Primitive.to_proto(self.target_service_accounts):
            request.resource.target_service_accounts.extend(
                Primitive.to_proto(self.target_service_accounts))
        if Primitive.to_proto(self.target_tags):
            request.resource.target_tags.extend(
                Primitive.to_proto(self.target_tags))
        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeFirewall(request)
        self.creation_timestamp = Primitive.from_proto(
            response.creation_timestamp)
        self.description = Primitive.from_proto(response.description)
        self.direction = FirewallDirectionEnum.from_proto(response.direction)
        self.disabled = Primitive.from_proto(response.disabled)
        self.id = Primitive.from_proto(response.id)
        self.log_config = FirewallLogConfig.from_proto(response.log_config)
        self.name = Primitive.from_proto(response.name)
        self.network = Primitive.from_proto(response.network)
        self.priority = Primitive.from_proto(response.priority)
        self.self_link = Primitive.from_proto(response.self_link)
        self.project = Primitive.from_proto(response.project)
        self.allowed = FirewallAllowedArray.from_proto(response.allowed)
        self.denied = FirewallDeniedArray.from_proto(response.denied)
        self.destination_ranges = Primitive.from_proto(
            response.destination_ranges)
        self.source_ranges = Primitive.from_proto(response.source_ranges)
        self.source_service_accounts = Primitive.from_proto(
            response.source_service_accounts)
        self.source_tags = Primitive.from_proto(response.source_tags)
        self.target_service_accounts = Primitive.from_proto(
            response.target_service_accounts)
        self.target_tags = Primitive.from_proto(response.target_tags)