Liking cljdoc? Tell your friends :D

goog.workspace.people

Clojure wrapper for the Google People API v1.

Provides idiomatic Clojure functions for the personal-contacts surface (CRUD on a user's own contacts + photos), contact-group labels (the user's organizational scheme on top of those contacts — list / get / batchGet / create / update / delete / members.modify), domain directory lookups (search + list), and the auto-collected "Other contacts" surface.

Auth: use csl/scoped-delegated-credentials with the appropriate scope and the impersonation target whose contacts you operate on:

  • PeopleServiceScopes/CONTACTS_READONLY — reads on personal contacts
  • PeopleServiceScopes/CONTACTS — full read+write on personal contacts
  • PeopleServiceScopes/CONTACTS_OTHER_READONLY — reads on Other contacts only
  • PeopleServiceScopes/DIRECTORY_READONLY — reads on the domain directory
  • PeopleServiceScopes/USERINFO_EMAIL, PeopleServiceScopes/USERINFO_PROFILE, PeopleServiceScopes/USER_*_READ (granular per-field reads on the authenticated user's own profile)

This library wraps the contacts + contactGroups + directory + otherContacts surface. It does NOT wrap batchCreateContacts / batchUpdateContacts / batchDeleteContacts, otherContacts.copyOtherContactToMyContactsGroup, or the legacy Google Contacts v3 GData API — each waits for a real consumer need before being wrapped.

REQUIRED OPTS — VALIDATED AT THE WRAPPER The People API treats personFields / readMask / updatePersonFields as load-bearing. Omitting them produces opaque HTTP-400s from Google with poor diagnostics. The wrapper enforces them up-front:

  • Every read (get-person, get-people, list-connections, search-contacts, create-contact, update-contact-photo, delete-contact-photo) REQUIRES :person-fields — a comma-separated string of Person field paths (e.g. "names,emailAddresses,phoneNumbers").
  • Every directory + otherContacts read (search-directory-people, list-directory-people, list-other-contacts, search-other-contacts) REQUIRES :read-mask — same shape as :person-fields, distinct parameter name in Google's API; we preserve that distinction.
  • update-contact REQUIRES :etag (on the body, threaded through :update-person-fields opt — the API uses optimistic concurrency).
  • update-contact REQUIRES :update-person-fields — controls which fields the API will modify (separate from :person-fields, which controls the response shape).
  • update-contact-group REQUIRES :update-group-fields (in opts — controls which ContactGroup body fields the API will apply) AND :etag (on the :contact-group body — optimistic concurrency).
  • modify-contact-group-members REQUIRES at least one of :resource-names-to-add / :resource-names-to-remove (non-empty).

contactGroups carries THREE distinct field-mask opts:

  • :group-fields — query-param mask on list / get / batchGet, controlling response shape. OPTIONAL — Google does not reject if omitted, but omitting yields a sparse ContactGroup (resourceName + etag only). Strongly recommended to pass it.
  • :read-group-fields — body field on create / update, controlling the RESPONSE shape after the write. Optional.
  • :update-group-fields — body field on update only, controlling WHICH fields the API applies. Required.

When required, omitted opts return {:error {:message "..." :type :missing-required-opt :opt :<the-key>}} without hitting the network.

ETAG CONTRACT (update-contact, update-contact-group) People API uses optimistic concurrency on Person AND ContactGroup updates. Caller must:

  1. Fetch the current resource via (get-person ...) / (get-contact- group ...); the response carries :etag.
  2. Pass that :etag through unchanged on the body of update-contact (:etag on the Person body) or update-contact-group (:etag on the :contact-group body, threaded inside the UpdateContactGroupRequest).
  3. If the etag mismatches (concurrent write happened), Google rejects with HTTP 400; caller refetches and retries. The wrapper does NOT auto-refetch — it would hide a network call in what is otherwise a thin pass-through layer.

PAGINATION All list / search functions return {:data [...] :next-page-token "..."}. :next-page-token is absent when there are no further pages. Compatible with csl/execute-list-all for callers that want the full result set.

CLASS COLLISIONS Person, Name, EmailAddress, PhoneNumber, Address, Organization, Date, Status, Empty, Membership, Event, ContactGroup, CreateContactGroupRequest, UpdateContactGroupRequest, ModifyContactGroupMembersRequest model classes are intentionally NOT imported. Typed bodies are constructed via JSON round-trip through csl/clj->json + GsonFactory; responses are read via csl/->clj (java.util.Map walking). Only the service classes (PeopleService, PeopleService$Builder, PeopleServiceScopes) and GoogleNetHttpTransport are imported.

All functions return {:data ...} on success or {:error ...} on failure.

Clojure wrapper for the Google People API v1.

Provides idiomatic Clojure functions for the personal-contacts surface
(CRUD on a user's own contacts + photos), contact-group labels (the
user's organizational scheme on top of those contacts — list / get /
batchGet / create / update / delete / members.modify), domain
directory lookups (search + list), and the auto-collected "Other
contacts" surface.

Auth: use csl/scoped-delegated-credentials with the appropriate scope
and the impersonation target whose contacts you operate on:

- PeopleServiceScopes/CONTACTS_READONLY        — reads on personal contacts
- PeopleServiceScopes/CONTACTS                 — full read+write on personal contacts
- PeopleServiceScopes/CONTACTS_OTHER_READONLY  — reads on Other contacts only
- PeopleServiceScopes/DIRECTORY_READONLY       — reads on the domain directory
- PeopleServiceScopes/USERINFO_EMAIL,
  PeopleServiceScopes/USERINFO_PROFILE,
  PeopleServiceScopes/USER_*_READ (granular per-field reads on the
                                    authenticated user's own profile)

This library wraps the contacts + contactGroups + directory +
otherContacts surface. It does NOT wrap batchCreateContacts /
batchUpdateContacts / batchDeleteContacts,
otherContacts.copyOtherContactToMyContactsGroup, or the legacy Google
Contacts v3 GData API — each waits for a real consumer need before
being wrapped.

REQUIRED OPTS — VALIDATED AT THE WRAPPER
The People API treats personFields / readMask / updatePersonFields as
load-bearing. Omitting them produces opaque HTTP-400s from Google with
poor diagnostics. The wrapper enforces them up-front:

- Every read (get-person, get-people, list-connections, search-contacts,
  create-contact, update-contact-photo, delete-contact-photo) REQUIRES
  :person-fields — a comma-separated string of Person field paths
  (e.g. "names,emailAddresses,phoneNumbers").
- Every directory + otherContacts read (search-directory-people,
  list-directory-people, list-other-contacts, search-other-contacts)
  REQUIRES :read-mask — same shape as :person-fields, distinct
  parameter name in Google's API; we preserve that distinction.
- update-contact REQUIRES :etag (on the body, threaded through
  :update-person-fields opt — the API uses optimistic concurrency).
- update-contact REQUIRES :update-person-fields — controls which
  fields the API will modify (separate from :person-fields, which
  controls the response shape).
- update-contact-group REQUIRES :update-group-fields (in opts —
  controls which ContactGroup body fields the API will apply) AND
  :etag (on the :contact-group body — optimistic concurrency).
- modify-contact-group-members REQUIRES at least one of
  :resource-names-to-add / :resource-names-to-remove (non-empty).

contactGroups carries THREE distinct field-mask opts:
- :group-fields       — query-param mask on list / get / batchGet,
                        controlling response shape. OPTIONAL —
                        Google does not reject if omitted, but
                        omitting yields a sparse ContactGroup
                        (resourceName + etag only). Strongly
                        recommended to pass it.
- :read-group-fields  — body field on create / update, controlling
                        the RESPONSE shape after the write.
                        Optional.
- :update-group-fields — body field on update only, controlling
                         WHICH fields the API applies. Required.

When required, omitted opts return
{:error {:message "..."
         :type    :missing-required-opt
         :opt     :<the-key>}}
without hitting the network.

ETAG CONTRACT (update-contact, update-contact-group)
People API uses optimistic concurrency on Person AND ContactGroup
updates. Caller must:
1. Fetch the current resource via (get-person ...) / (get-contact-
   group ...); the response carries :etag.
2. Pass that :etag through unchanged on the body of update-contact
   (:etag on the Person body) or update-contact-group (:etag on the
   :contact-group body, threaded inside the UpdateContactGroupRequest).
3. If the etag mismatches (concurrent write happened), Google rejects
   with HTTP 400; caller refetches and retries.
The wrapper does NOT auto-refetch — it would hide a network call in
what is otherwise a thin pass-through layer.

PAGINATION
All list / search functions return {:data [...] :next-page-token "..."}.
:next-page-token is absent when there are no further pages. Compatible
with csl/execute-list-all for callers that want the full result set.

CLASS COLLISIONS
Person, Name, EmailAddress, PhoneNumber, Address, Organization,
Date, Status, Empty, Membership, Event, ContactGroup,
CreateContactGroupRequest, UpdateContactGroupRequest,
ModifyContactGroupMembersRequest model classes are intentionally NOT
imported. Typed bodies are constructed via JSON round-trip through
csl/clj->json + GsonFactory; responses are read via csl/->clj
(java.util.Map walking). Only the service classes
(PeopleService, PeopleService$Builder, PeopleServiceScopes) and
GoogleNetHttpTransport are imported.

All functions return {:data ...} on success or {:error ...} on failure.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close