コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
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)