def delete(ctx, id, indent, sort, output): """ a single contact """ client = domain_shared_contacts_client.Client(**ctx.obj) key = 'http://www.google.com/m8/feeds/contacts/%s/base/%s' result = client.delete_contact(key % (ctx.obj['domain'], id)) json.dump(result, output, sort_keys=sort, indent=indent)
def create(ctx, contact, indent, sort, output): """ a single contact """ client = domain_shared_contacts_client.Client(**ctx.obj) contact = client.create_contact(contact) json.dump(contact, output, default=contacts_helper.convert_contacts, sort_keys=sort, indent=indent)
def list_contacts(ctx, indent, sort, output): """ all contacts """ client = domain_shared_contacts_client.Client(**ctx.obj) contacts = client.get_contacts() json.dump(contacts, output, default=contacts_helper.convert_contacts, sort_keys=sort, indent=indent)
def read(ctx, id, indent, sort, output): """ a single contact """ client = domain_shared_contacts_client.Client(**ctx.obj) key = 'http://www.google.com/m8/feeds/contacts/%s/base/%s' contact = client.read_contact(key % (ctx.obj['domain'], id)) json.dump(contact, output, default=contacts_helper.convert_contact, sort_keys=sort, indent=indent)
def update(ctx, contact, indent, sort, output): """ a single contact """ client = domain_shared_contacts_client.Client(**ctx.obj) with open(contact) as fp: data = json.load(fp) contact = client.update_contact(data['id'], contact) json.dump(contact, output, default=contacts_helper.convert_contact, sort_keys=sort, indent=indent)