def create_customer(self, customer_id, customer_name):
     """
     Client function to call the rpc for creating customer
     """
     customer_info = customer_pb2.Customer()
     customer_info.id = customer_id
     customer_info.name = customer_name
     client_request = customer_pb2.CreateCustomerRequest(
         request=customer_info)
     return self.stub.CreateCustomer(client_request)
Exemplo n.º 2
0
#!/usr/bin/env python

import urllib

import customer_pb2

if __name__ == '__main__':
    customer = customer_pb2.Customer()
    customers_read = urllib.urlopen('http://localhost:8080/customers/1').read()
    customer.ParseFromString(customers_read)
    print customer
Exemplo n.º 3
0
import customer_pb2

PB_FILE_PATH = 'customer.pb'
JSON_FILE_PATH = 'customer.json'

organization = customer_pb2.Organization()
organization.name = 'organization'
customer1 = customer_pb2.Customer()
customer1.id = 1
customer1.firstName = 'Chris'
customer1.lastName = 'Richardson'
email = customer1.email.add()
email.email = '*****@*****.**'
email.type = customer1.PROFESSIONAL
organization.customer.append(customer1)
customer2 = customer_pb2.Customer()
customer2.id = 2
customer2.firstName = 'Josh'
customer2.lastName = 'Long'
email = customer2.email.add()
email.email = '*****@*****.**'
email.type = customer2.PROFESSIONAL
organization.customer.append(customer2)
customer3 = customer_pb2.Customer()
customer3.id = 3
customer3.firstName = 'Matt'
customer3.lastName = 'Stine'
email = customer3.email.add()
email.email = '*****@*****.**'
email.type = customer3.PROFESSIONAL
organization.customer.append(customer3)