コード例 #1
0
    def apply(self):
        stub = firewall_policy_association_pb2_grpc.ComputeBetaFirewallPolicyAssociationServiceStub(
            channel.Channel()
        )
        request = (
            firewall_policy_association_pb2.ApplyComputeBetaFirewallPolicyAssociationRequest()
        )
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeBetaFirewallPolicyAssociation(request)
        self.name = Primitive.from_proto(response.name)
        self.attachment_target = Primitive.from_proto(response.attachment_target)
        self.firewall_policy = Primitive.from_proto(response.firewall_policy)
        self.short_name = Primitive.from_proto(response.short_name)
コード例 #2
0
    def list(self, firewallPolicy, service_account_file=""):
        stub = firewall_policy_association_pb2_grpc.ComputeBetaFirewallPolicyAssociationServiceStub(
            channel.Channel())
        request = (firewall_policy_association_pb2.
                   ListComputeBetaFirewallPolicyAssociationRequest())
        request.service_account_file = service_account_file
        request.FirewallPolicy = firewallPolicy

        return stub.ListComputeBetaFirewallPolicyAssociation(request).items