Common Lisp ODATA Client

Table of Contents

Next:   [Contents][Index]

Top

CL-ODATA-CLIENT is a Common Lisp client for accessing ODATA services.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

CL-ODATA-CLIENT is a Common Lisp client for accessing ODATA services.


Next: , Previous: , Up: Top   [Contents][Index]

2 Installation


Next: , Previous: , Up: Top   [Contents][Index]

3 Usage


Next: , Previous: , Up: Top   [Contents][Index]

4 CL-ODATA-CLIENT Basic Tutorial

This is CL-ODATA-CLIENT version of TripPin tutorial. See the original tutorial at: https://www.odata.org/getting-started/basic-tutorial/

The tutorial uses a sample service called TripPin based on OData V4. Generally speaking, TripPin provides a service that can manage people’s trips. The service is designed for below purposes:

Build a service that will cover as many features for OData V4 as possible. Build a more real world service, and will use it to build an end-to-end ecosystem. Make a service reference for developers to follow when they try to build an OData service.

https://services.odata.org/V4/TripPinServiceRW


Next: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.1 Introduction

The Open Data Protocol (OData) is a data access protocol built on core protocols like HTTP and commonly accepted methodologies like REST for the web. There are various kinds of libraries and tools can be used to consume OData services. But for beginners and those who want to write their own libraries, the pure HTTP requests and responses are also very important. This documentation will not cover every feature details for OData V4 services but will try to cover various typical scenarios. If you want to have a more detailed understanding, please refer to OData Documentation.

We start by defining a package:

  (defpackage :odata.trip-pin
    (:use :cl :odata-client :odata/lang :arrows :access))
   
  (in-package :odata.trip-pin)

and declaring the service urls:

  (defparameter +trip-pin-base+ "https://services.odata.org/V4/TripPinServiceRW")

TripPin services uses a special url for read/write, so we get that:

  (defparameter +trip-pin-modify+
    (multiple-value-bind (response status headers modify-url)
        (drakma:http-request +trip-pin-base+)
      (quri:uri (princ-to-string modify-url))))

Next: , Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.2 Requesting Data

OData services support requests for data via HTTP GET requests.


Up: Requesting Data   [Contents][Index]

4.2.1 Requesting Entity Collections

The request below returns the the collection of Person People.

  (-> +trip-pin-modify+
      (collection "People")
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('russellwhyte')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('russellwhyte')")
  (:user-name . "russellwhyte") (:first-name . "Russell")
  (:last-name . "Whyte") (:emails "Russell@example.com" "Russell@contoso.com")
  (:address-info
   ((:address . "187 Suffolk Ln.")
    (:city (:country-region . "United States") (:name . "Boise")
     (:region . "ID"))))
  (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:user-name . "scottketchum") (:first-name . "Scott")
  (:last-name . "Ketchum") (:emails "Scott@example.com")
  (:address-info
   ((:address . "2817 Milton Dr.")
    (:city (:country-region . "United States") (:name . "Albuquerque")
     (:region . "NM"))))
  (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('ronaldmundy')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('ronaldmundy')")
  (:user-name . "ronaldmundy") (:first-name . "Ronald") (:last-name . "Mundy")
  (:emails "Ronald@example.com" "Ronald@contoso.com") (:address-info)
  (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('javieralfred')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('javieralfred')")
  (:user-name . "javieralfred") (:first-name . "Javier")
  (:last-name . "Alfred") (:emails "Javier@example.com" "Javier@contoso.com")
  (:address-info
   ((:address . "89 Jefferson Way Suite 2")
    (:city (:country-region . "United States") (:name . "Portland")
     (:region . "WA"))))
  (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('willieashmore')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('willieashmore')")
  (:user-name . "willieashmore") (:first-name . "Willie")
  (:last-name . "Ashmore") (:emails "Willie@example.com" "Willie@contoso.com")
  (:address-info) (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('vincentcalabrese')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('vincentcalabrese')")
  (:user-name . "vincentcalabrese") (:first-name . "Vincent")
  (:last-name . "Calabrese")
  (:emails "Vincent@example.com" "Vincent@contoso.com")
  (:address-info
   ((:address . "55 Grizzly Peak Rd.")
    (:city (:country-region . "United States") (:name . "Butte")
     (:region . "MT"))))
  (:gender . "Male") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('clydeguess')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('clydeguess')")
  (:user-name . "clydeguess") (:first-name . "Clyde") (:last-name . "Guess")
  (:emails "Clyde@example.com") (:address-info) (:gender . "Male")
  (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('keithpinckney')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('keithpinckney')")
  (:user-name . "keithpinckney") (:first-name . "Keith")
  (:last-name . "Pinckney") (:emails "Keith@example.com" "Keith@contoso.com")
  (:address-info) (:gender . "Male") (:concurrency . 637145265160790083)))

Next: , Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.3 Requesting an Individual Entity by ID

The request below returns an individual entity of type Person by the given UserName "russellwhyte"

  (-> +trip-pin-modify+
      (collection "People")
      (id "russellwhyte")
      (fetch))

((:odata-context
  . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/$metadata#People/$entity")
 (:odata-id
  . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('russellwhyte')")
 (:odata-etag . "W/\"08D7983E303B2043\"")
 (:odata-edit-link
  . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('russellwhyte')")
 (:user-name . "russellwhyte") (:first-name . "Russell") (:last-name . "Whyte")
 (:emails "Russell@example.com" "Russell@contoso.com")
 (:address-info
  ((:address . "187 Suffolk Ln.")
   (:city (:country-region . "United States") (:name . "Boise")
    (:region . "ID"))))
 (:gender . "Male") (:concurrency . 637145265160790083))

Next: , Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.4 Requesting an Individual Property

To address an entity property clients append a path segment containing property name to the URL of the entity. If the property has a complex type, properties of that value can be addressed by further property name composition. First let’s take a look at how to get a simple property. The request below returns the Name property of an Airport.

  (-> +trip-pin-modify+
      (collection "Airports")
      (id "KSFO")
      (property "Name")
      (fetch :value))

"San Francisco International Airport"

Then let’s see how to get a property value of a complex type. The request below returns the Address of the complex type Location in an Airport.

  (-> +trip-pin-modify+
      (collection "Airports")
      (id "KSFO")
      (property "Location")
      (property "Address")
      (fetch :value))

"South McDonnell Road, San Francisco, CA 94128"

Next: , Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.5 Querying Data

OData supports various kinds of query options for querying data. This section will help you go through the common scenarios for these query options. System Query Option $filter

The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response.


Next: , Up: Querying Data   [Contents][Index]

4.5.1 Basic predicates, built-in functions

There are several kinds of basic predicates and built-in functions for $filter, including logical operators and arithmetic operators. For more detailed information, please refer to OData V4 URL Conventions Document. The request below using $filter to get people with FirstName "Scott".

Just use raw expressions as $filter input.

  (-> +trip-pin-modify+
      (collection "People")
      ($filter "FirstName eq 'Scott'")
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:user-name . "scottketchum") (:first-name . "Scott")
  (:last-name . "Ketchum") (:emails "Scott@example.com")
  (:address-info
   ((:address . "2817 Milton Dr.")
    (:city (:country-region . "United States") (:name . "Albuquerque")
     (:region . "NM"))))
  (:gender . "Male") (:concurrency . 637145265160790083)))

Or Lisp based expressions:

  (-> +trip-pin-modify+
      (collection "People")
      ($filter '(:= "FirstName" "Scott"))
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('scottketchum')")
  (:user-name . "scottketchum") (:first-name . "Scott")
  (:last-name . "Ketchum") (:emails "Scott@example.com")
  (:address-info
   ((:address . "2817 Milton Dr.")
    (:city (:country-region . "United States") (:name . "Albuquerque")
     (:region . "NM"))))
  (:gender . "Male") (:concurrency . 637145265160790083)))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.2 Filter on Complex Type

$filter can also work on complex type. The request below returns airports with "San Francisco" contained in its Address. And Address is property of complex type Location.

  (-> +trip-pin-modify+
      (collection "Airports")
      ($filter "contains(Location/Address, 'San Francisco')")
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/Airports('KSFO')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/Airports('KSFO')")
  (:icao-code . "KSFO") (:name . "San Francisco International Airport")
  (:iata-code . "SFO")
  (:location (:address . "South McDonnell Road, San Francisco, CA 94128")
   (:city (:country-region . "United States") (:name . "San Francisco")
    (:region . "California"))
   (:loc (:type . "Point") (:coordinates -122.374725 37.61889)
    (:crs (:type . "name") (:properties (:name . "EPSG:4326")))))))
  (-> +trip-pin-modify+
      (collection "Airports")
      ($filter '(:contains "Location/Address" "San Francisco"))
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/Airports('KSFO')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/Airports('KSFO')")
  (:icao-code . "KSFO") (:name . "San Francisco International Airport")
  (:iata-code . "SFO")
  (:location (:address . "South McDonnell Road, San Francisco, CA 94128")
   (:city (:country-region . "United States") (:name . "San Francisco")
    (:region . "California"))
   (:loc (:type . "Point") (:coordinates -122.374725 37.61889)
    (:crs (:type . "name") (:properties (:name . "EPSG:4326")))))))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.3 Filter on Enum Properties

The request below returns all female People of entity type Person. The Gender is a property of Enum type.

  (-> +trip-pin-modify+
      (collection "People")
      ($filter `(:eq "Gender" ,+person-gender/female+))
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('elainestewart')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('elainestewart')")
  (:user-name . "elainestewart") (:first-name . "Elaine")
  (:last-name . "Stewart") (:emails "Elaine@example.com" "Elaine@contoso.com")
  (:address-info) (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('salliesampson')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('salliesampson')")
  (:user-name . "salliesampson") (:first-name . "Sallie")
  (:last-name . "Sampson") (:emails "Sallie@example.com" "Sallie@contoso.com")
  (:address-info
   ((:address . "87 Polk St. Suite 5")
    (:city (:country-region . "United States") (:name . "San Francisco")
     (:region . "CA")))
   ((:address . "89 Chiaroscuro Rd.")
    (:city (:country-region . "United States") (:name . "Portland")
     (:region . "OR"))))
  (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('jonirosales')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('jonirosales')")
  (:user-name . "jonirosales") (:first-name . "Joni") (:last-name . "Rosales")
  (:emails "Joni@example.com" "Joni@contoso.com") (:address-info)
  (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('georginabarlow')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('georginabarlow')")
  (:user-name . "georginabarlow") (:first-name . "Georgina")
  (:last-name . "Barlow")
  (:emails "Georgina@example.com" "Georgina@contoso.com") (:address-info)
  (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('angelhuffman')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('angelhuffman')")
  (:user-name . "angelhuffman") (:first-name . "Angel")
  (:last-name . "Huffman") (:emails "Angel@example.com") (:address-info)
  (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('laurelosborn')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('laurelosborn')")
  (:user-name . "laurelosborn") (:first-name . "Laurel")
  (:last-name . "Osborn") (:emails "Laurel@example.com" "Laurel@contoso.com")
  (:address-info) (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('sandyosborn')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('sandyosborn')")
  (:user-name . "sandyosborn") (:first-name . "Sandy") (:last-name . "Osborn")
  (:emails "Sandy@example.com" "Sandy@contoso.com") (:address-info)
  (:gender . "Female") (:concurrency . 637145265160790083))
 ((:odata-id
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('ursulabright')")
  (:odata-etag . "W/\"08D7983E303B2043\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(wgkqtxlasrgtwhbtgoqbxc1l))/TripPinServiceRW/People('ursulabright')")
  (:user-name . "ursulabright") (:first-name . "Ursula")
  (:last-name . "Bright") (:emails "Ursula@example.com" "Ursula@contoso.com")
  (:address-info) (:gender . "Female") (:concurrency . 637145265160790083)))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.4 System Query Option $orderby

The $orderby system query option allows clients to request resources in either ascending order using asc or descending order using desc. If asc or desc not specified, then the resources will be ordered in ascending order. The request below orders Trips on property EndsAt in descending order.

  (-> +trip-pin-modify+
      (collection "People")
      (id "scottketchum")
      (property "Trips")
      ($orderby "EndsAt" :desc)
      (fetch :collection))

(((:trip-id . 2004) (:share-id . "f94e9116-8bdd-4dac-ab61-08438d0d9a71")
  (:description . "Trip from Shanghai to Beijing") (:name . "Trip in Beijing")
  (:budget . 11000) (:starts-at . "2014-02-01T00:00:00Z")
  (:ends-at . "2014-02-04T00:00:00Z") (:tags "Travel" "Beijing"))
 ((:trip-id . 0) (:share-id . "9d9b2fa0-efbf-490e-a5e3-bac8f7d47354")
  (:description
   . "Trip from San Francisco to New York City. Nice trip with two friends. It is a 4 days' trip. We actually had a client meeting, but we also took one to go sightseeings in New York.")
  (:name . "Trip in US") (:budget . 3000) (:starts-at . "2014-01-01T00:00:00Z")
  (:ends-at . "2014-01-04T00:00:00Z")
  (:tags "Trip in New York" "business" "sightseeing")))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.5 System Query Option $top and $skip

The $top system query option requests the number of items in the queried collection to be included in the result. The $skip query option requests the number of items in the queried collection that are to be skipped and not included in the result. The request below returns the first two people of the People entity set.

  (-> +trip-pin-modify+
      (collection "People")
      ($top 2) 
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('russellwhyte')")
  (:odata-etag . "W/\"08D799E6ED7BA93B\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('russellwhyte')")
  (:user-name . "russellwhyte") (:first-name . "Russell")
  (:last-name . "Whyte") (:emails "Russell@example.com" "Russell@contoso.com")
  (:address-info
   ((:address . "187 Suffolk Ln.")
    (:city (:country-region . "United States") (:name . "Boise")
     (:region . "ID"))))
  (:gender . "Male") (:concurrency . 637147089402046779))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('scottketchum')")
  (:odata-etag . "W/\"08D799E6ED7BA93B\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('scottketchum')")
  (:user-name . "scottketchum") (:first-name . "Scott")
  (:last-name . "Ketchum") (:emails "Scott@example.com")
  (:address-info
   ((:address . "2817 Milton Dr.")
    (:city (:country-region . "United States") (:name . "Albuquerque")
     (:region . "NM"))))
  (:gender . "Male") (:concurrency . 637147089402046779)))

The request below returns people starting with the 19th people of the entity set People

  (-> +trip-pin-modify+
      (collection "People")
      ($skip 18) 
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('genevievereeves')")
  (:odata-etag . "W/\"08D799E6ED7BA93B\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('genevievereeves')")
  (:user-name . "genevievereeves") (:first-name . "Genevieve")
  (:last-name . "Reeves")
  (:emails "Genevieve@example.com" "Genevieve@contoso.com") (:address-info)
  (:gender . "Female") (:concurrency . 637147089402046779))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('kristakemp')")
  (:odata-etag . "W/\"08D799E6ED7BA93B\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('kristakemp')")
  (:user-name . "kristakemp") (:first-name . "Krista") (:last-name . "Kemp")
  (:emails "Krista@example.com") (:address-info) (:gender . "Female")
  (:concurrency . 637147089402046779)))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.6 System Query Option $count

The $count system query option allows clients to request a count of the matching resources included with the resources in the response. The request below returns the total number of people in the collection.


Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.7 System Query Option $expand

The $expand system query option specifies the related resources to be included in line with retrieved resources. The request below returns people with navigation property Friends of a Person

  (-> +trip-pin-modify+
      (collection "People")
      (id "keithpinckney")
      ($expand "Friends")
      (fetch))

((:odata-context
  . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/$metadata#People/$entity")
 (:odata-id
  . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('keithpinckney')")
 (:odata-etag . "W/\"08D799E6ED7BA93B\"")
 (:odata-edit-link
  . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('keithpinckney')")
 (:user-name . "keithpinckney") (:first-name . "Keith")
 (:last-name . "Pinckney") (:emails "Keith@example.com" "Keith@contoso.com")
 (:address-info) (:gender . "Male") (:concurrency . 637147089402046779)
 (:friends
  ((:odata-id
    . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('clydeguess')")
   (:odata-etag . "W/\"08D799E6ED7BA93B\"")
   (:odata-edit-link
    . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('clydeguess')")
   (:user-name . "clydeguess") (:first-name . "Clyde") (:last-name . "Guess")
   (:emails "Clyde@example.com") (:address-info) (:gender . "Male")
   (:concurrency . 637147089402046779))
  ((:odata-id
    . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('marshallgaray')")
   (:odata-etag . "W/\"08D799E6ED7BA93B\"")
   (:odata-edit-link
    . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('marshallgaray')")
   (:user-name . "marshallgaray") (:first-name . "Marshall")
   (:last-name . "Garay")
   (:emails "Marshall@example.com" "Marshall@contoso.com") (:address-info)
   (:gender . "Male") (:concurrency . 637147089402046779))))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.8 System Query Option $select

The $select system query option allows the clients to requests a limited set of properties for each entity or complex type. The request below returns Name and IcaoCode of all Airports.

  (-> +trip-pin-modify+
      (collection "Airports")
      ($select '("Name" "IcaoCode"))
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KSFO')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KSFO')")
  (:name . "San Francisco International Airport") (:icao-code . "KSFO"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KLAX')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KLAX')")
  (:name . "Los Angeles International Airport") (:icao-code . "KLAX"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('ZSSS')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('ZSSS')")
  (:name . "Shanghai Hongqiao International Airport") (:icao-code . "ZSSS"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('ZBAA')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('ZBAA')")
  (:name . "Beijing Capital International Airport") (:icao-code . "ZBAA"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KJFK')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('KJFK')")
  (:name . "John F. Kennedy International Airport") (:icao-code . "KJFK"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('LIRA')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('LIRA')")
  (:name . "Rome Ciampino Airport") (:icao-code . "LIRA"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('CYYZ')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('CYYZ')")
  (:name . "Toronto Pearson International Airport") (:icao-code . "CYYZ"))
 ((:odata-id
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('YSSY')")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/Airports('YSSY')")
  (:name . "Sydney Airport") (:icao-code . "YSSY")))

Next: , Previous: , Up: Querying Data   [Contents][Index]

4.5.9 System Query Option $search

The $search system query option restricts the result to include only those entities matching the specified search expression. The definition of what it means to match is dependent upon the implementation. The request below get all People who has ’Boise’ in their contents.

serviceRoot/People?$search=United

  (-> +trip-pin-modify+
      (collection "People")
      ($search "United")
      (fetch :collection))

(((:odata-id
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('russellwhyte')")
  (:odata-etag . "W/\"08D79AA36F81DD60\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('russellwhyte')")
  (:user-name . "russellwhyte") (:first-name . "Russell")
  (:last-name . "Whyte") (:emails "Russell@example.com" "Russell@contoso.com")
  (:address-info
   ((:address . "187 Suffolk Ln.")
    (:city (:country-region . "United States") (:name . "Boise")
     (:region . "ID"))))
  (:gender . "Male") (:concurrency . 637147899037343072))
 ((:odata-id
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('scottketchum')")
  (:odata-etag . "W/\"08D79AA36F81DD60\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('scottketchum')")
  (:user-name . "scottketchum") (:first-name . "Scott")
  (:last-name . "Ketchum") (:emails "Scott@example.com")
  (:address-info
   ((:address . "2817 Milton Dr.")
    (:city (:country-region . "United States") (:name . "Albuquerque")
     (:region . "NM"))))
  (:gender . "Male") (:concurrency . 637147899037343072))
 ((:odata-id
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('javieralfred')")
  (:odata-etag . "W/\"08D79AA36F81DD60\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('javieralfred')")
  (:user-name . "javieralfred") (:first-name . "Javier")
  (:last-name . "Alfred") (:emails "Javier@example.com" "Javier@contoso.com")
  (:address-info
   ((:address . "89 Jefferson Way Suite 2")
    (:city (:country-region . "United States") (:name . "Portland")
     (:region . "WA"))))
  (:gender . "Male") (:concurrency . 637147899037343072))
 ((:odata-id
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('vincentcalabrese')")
  (:odata-etag . "W/\"08D79AA36F81DD60\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('vincentcalabrese')")
  (:user-name . "vincentcalabrese") (:first-name . "Vincent")
  (:last-name . "Calabrese")
  (:emails "Vincent@example.com" "Vincent@contoso.com")
  (:address-info
   ((:address . "55 Grizzly Peak Rd.")
    (:city (:country-region . "United States") (:name . "Butte")
     (:region . "MT"))))
  (:gender . "Male") (:concurrency . 637147899037343072))
 ((:odata-id
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('salliesampson')")
  (:odata-etag . "W/\"08D79AA36F81DD60\"")
  (:odata-edit-link
   . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/People('salliesampson')")
  (:user-name . "salliesampson") (:first-name . "Sallie")
  (:last-name . "Sampson") (:emails "Sallie@example.com" "Sallie@contoso.com")
  (:address-info
   ((:address . "87 Polk St. Suite 5")
    (:city (:country-region . "United States") (:name . "San Francisco")
     (:region . "CA")))
   ((:address . "89 Chiaroscuro Rd.")
    (:city (:country-region . "United States") (:name . "Portland")
     (:region . "OR"))))
  (:gender . "Female") (:concurrency . 637147899037343072)))

Previous: , Up: Querying Data   [Contents][Index]

4.5.10 Lambda Operators

OData defines two operators any and all that evaluate a Boolean expression on a collection. They can work on either collection properties or collection of entities.

The request below returns People with Emails containing "ll@contoso.com". The Emails is a collection of primitive type string.

GET serviceRoot/People?$filter=Emails/any(s:endswith(s, ’contoso.com’))


Next: , Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.6 Data Modification

Updatable OData services support Create, Update and Delete operation for some or all exposed entities.


Next: , Up: Data Modification   [Contents][Index]

4.6.1 Create an Entity

To create an entity in a collection, the client sends a POST request to that collection’s URL. The POST body MUST contain a single valid entity representation. The request below creates a Person which contains complex type and collection property.

  
   
  (defparameter *p* '(("@odata.type" . "Microsoft.OData.SampleService.Models.TripPin.Person")
                                ("UserName" . "teresa")
                                ("FirstName" . "Teresa")
                                ("LastName" . "Gilbert")
                                ("Gender" . "Female")
                                ("Emails" . ("teresa@example.com" "teresa@contoso.com"))
                                ("AddressInfo" . ((("Address" . "1 Suffolk Ln.")
                                                  ("City" . (("CountryRegion" . "United States")
                                                             ("Name" . "Boise")
                                                             ("Region" . "ID"))))))))
   
  (princ 
    (-> +trip-pin-modify+
      (collection "People")
      (post *p*)))
   
((odata-context
  . http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/$metadata#People/$entity)
 (odata-id
  . http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('teresa'))
 (odata-etag . W/"08D799ECFD4995C4")
 (odata-edit-link
  . http://services.odata.org/V4/(S(dbwnjvoyanwfvbktg1eu5zvg))/TripPinServiceRW/People('teresa'))
 (user-name . teresa) (first-name . Teresa) (last-name . Gilbert)
 (emails teresa@example.com teresa@contoso.com)
 (address-info
  ((address . 1 Suffolk Ln.)
   (city (country-region . United States) (name . Boise) (region . ID))))
 (gender . Female) (concurrency . 637147115437004228))

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.2 Remove an Entity

The request below deletes the Person with UserName ’vincentcalabrese’. DELETE serviceRoot/People(’vincentcalabrese’)

  (-> +trip-pin-modify+
      (collection "People")
      (id "vincentcalabrese")
      (del))

nil

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.3 Update an Entity

The OData services SHOULD support PATCH as the preferred means of updating an entity. But also services MAY additionally support PUT. The request below update the Emails of a person using PATCH.

  (-> +trip-pin-modify+
     (collection "People")
     (id "russellwhyte")
     (update '(("@odata.type" . "Microsoft.OData.SampleService.Models.TripPin.Person")
               ("Emails" . ("Russell@example.com" "Russell@contoso.com" "newRussell@contoso.com")))))

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.4 Relationship Operations

Relationships from one entity to another are represented as navigation properties. Link to Related Entities

A successful POST request to a navigation property’s references collection adds a relationship to an existing entity. The request below adds ’vincentcalabrese’ to friends of ’scottketchum’.

  (-> +trip-pin-modify+
     (collection "People") (id "scottketchum")
     (property "Friends") ($ref)
     (link `(("@odata.context" . ,(quri:render-uri +trip-pin-modify+))
             ("@odata.id" . "People('vincentcalabrese')"))))

nil

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.5 Change a Link

A successful PUT request to a single-valued navigation property’s reference resource changes the related entity. The request below change the Airline of a Flight.

  (-> +trip-pin-modify+
                (collection "People")
                (id "russellwhyte")
                (path "Trips(0)"
                      "PlanItems(11)"
                      "Microsoft.OData.SampleService.Models.TripPin.Flight"
                      "Airline")
                (update-link `(("@odata.context" . ,(quri:render-uri +trip-pin-modify+))
             ("@odata.id" . "Airlines('FM')"))))

nil

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.6 Functions and Actions

OData supports custom operations (Actions and Functions). Functions are operations exposed by an OData service that MUST return data and MUST have no observable side effects. Actions are operations exposed by an OData service that MAY have side effects when invoked. Functions and actions both MAY bound to an entity type, primitive type, complex type, or a collection.

  1. Invoking Unbound Functions

    The function below returns the nearest airport with the input geography point.

      (-> +trip-pin-modify+
          (fcall 'get-nearest-airport :lat 33 :lon -118)
          (fetch))
    
    
    ((:odata-context
      . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/$metadata#Airports/$entity")
     (:odata-id
      . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/Airports('KLAX')")
     (:odata-edit-link
      . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/Airports('KLAX')")
     (:icao-code . "KLAX") (:name . "Los Angeles International Airport")
     (:iata-code . "LAX")
     (:location (:address . "1 World Way, Los Angeles, CA, 90045")
      (:city (:country-region . "United States") (:name . "Los Angeles")
       (:region . "California"))
      (:loc (:type . "Point") (:coordinates -118.40806 33.9425)
       (:crs (:type . "name") (:properties (:name . "EPSG:4326"))))))
    

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.7 Invoking Bound Functions

The request below returns the favorite airline of a person, in TripPin service, "favorite airline" means airline which user choose most times. The function GetFavoriteAirline() is bound to Person.

  (-> +trip-pin-modify+
      (collection "People")
      (id "russellwhyte")
      (fcall "Microsoft.OData.SampleService.Models.TripPin.GetFavoriteAirline")
      (fetch))

((:odata-context
  . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/$metadata#Airlines/$entity")
 (:odata-id
  . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/Airlines('AA')")
 (:odata-edit-link
  . "http://services.odata.org/V4/(S(jreo0syd1dcfhrharzudcfgy))/TripPinServiceRW/Airlines('AA')")
 (:airline-code . "AA") (:name . "American Airlines"))

Next: , Previous: , Up: Data Modification   [Contents][Index]

4.6.8 Invoking Unbound Actions

TripPin currently has no scenario supported for unbound actions.


Previous: , Up: Data Modification   [Contents][Index]

4.6.9 Invoking Bound Actions

The action below shares a trip to one of his friend. In TripPin service, by "share a trip" we mean that the owner and his friend now both have the trip and the trip share the same ShareId property.

  (-> +trip-pin-modify+
      (collection "People")
      (id "russellwhyte")
      (path "Microsoft.OData.SampleService.Models.TripPin.ShareTrip")
      (post '(("userName" . "scottketchum")
              ("tripId" . 0))))

nil

Previous: , Up: CL-ODATA-CLIENT Basic Tutorial   [Contents][Index]

4.7 Entities

Instead of working with raw data (Lisp association lists), it is also possible to work with wrapping CLOS objects, available in the ODATA/ENTITY package.

Use T as parameter to fetch. Instead of association lists, we get ENTITY objects:

  (-> +trip-pin-modify+
      (collection "People")
      (fetch t))
#<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/$metadata#People>

The elements of an entity set can be accessed with ODATA/ENTITY:ENTITY-SET-ELEMENTS:

  (-> +trip-pin-modify+
      (collection "People")
      (fetch t)
      (odata/entity:entity-set-elements))
(#<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('russellwhyte')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('scottketchum')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('ronaldmundy')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('javieralfred')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('willieashmore')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('vincentcalabrese')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('clydeguess')>
 #<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/People('keithpinckney')>)

As you can see, the elements of the entity set are also entities (wrapped objects).

To access entity objects, you can use either ODATA/ENTITY:GET-PROPERTY or ODATA/ENTITY:WITH-PROPERTIES macro:

  (let ((russell (-> +trip-pin-modify+
                     (collection "People")
                     (id "russellwhyte")
                     (fetch t))))
    (odata/entity:get-property russell :user-name))
russellwhyte
  (let ((russell (-> +trip-pin-modify+
                     (collection "People")
                     (id "russellwhyte")
                     (fetch t))))
    (odata/entity:with-properties (user-name) russell
      (concatenate 'string "Hello " user-name)))
Hello russellwhyte

One of the advantages of using entities over raw data is that you can call the api using entities as base, like in this example:

    ;; We get russell user entity first
  (let ((russell (-> +trip-pin-modify+
                     (collection "People")
                     (id "russellwhyte")
                     (fetch t))))
    ;; Then we use the entity as base for new api call and fetch its friends
    (-> russell
        (collection "Friends")
        (fetch t)))
#<http://services.odata.org/V4/(S(4olvgljic51nt3x0pqp5mpbl))/TripPinServiceRW/$metadata#People>

Next: , Previous: , Up: Top   [Contents][Index]

5 API


Next: , Up: API   [Contents][Index]

5.1 ODATA-CLIENT package

PACKAGE: ODATA-CLIENT

Provides core functions for interacting with an ODATA service.

External definitions

Variables

ODATA-CLIENT: *ACCESS-TOKEN*

ODATA service api token.

ODATA-CLIENT: *SERVICE-ROOT*

ODATA service base url.

Macros

Macro: ODATA-CLIENT:WITH-SERVICE-ROOT (base &body body)

Functions

Function: ODATA-CLIENT:ODATA-POST (uri data &key (json-encode t) authorization)

Make a POST request to ODATA service at URI.
DATA is the data to be posted. It is encoded using ‘ENCODE-JSON-TO-STRING’.

Function: ODATA-CLIENT:ODATA-GET* (uri &rest args &key $filter $expand)

Make an ODATA-GET request using *SERVICE-ROOT* as URL base.

Function: ODATA-CLIENT:ODATA-PUT (uri data &key (json-encode t) authorization)

Make a PUT (update) request to ODATA service at URI.
DATA is the data to be posted. It is encoded using ‘ENCODE-JSON-TO-STRING’.

Function: ODATA-CLIENT:ODATA-PATCH (uri data &key (json-encode t) authorization)

Make a PATCH request to ODATA service at URI.
DATA is the data to be posted. It is encoded using ‘ENCODE-JSON-TO-STRING’.

Function: ODATA-CLIENT:ODATA-GET (url &key $filter $expand authorization)

‘GET’ request on an ODATA service at URL.
$filter is an ODATA $filter expression.
$expand is an ODATA $expand expression.
AUTHORIZATION is the authorization token.

See: http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part1-protocol/odata-v4.0-errata03-os-part1-protocol-complete.html#_The_$filter_System

Classes

Class: ODATA-CLIENT:ODATA-REQUEST-ERROR

Class precedence list: odata-request-error, error, serious-condition, condition, t


Next: , Previous: , Up: API   [Contents][Index]

5.2 ODATA/LANG package

PACKAGE: ODATA/LANG

This package exports functions that are meant to be used with arrows syntax to interact with an ODATA service.

External definitions

Functions

Function: ODATA/LANG:FETCH (msgraph::url &optional type)
Function: ODATA/LANG:$FILTER (url exp)

Add ODATA $filter parameter to URL.

The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Resources for which the expression evaluates to false or to null, or which reference properties that are unavailable due to permissions, are omitted from the response.

See: ‘ODATA-CLIENT::compile-$filter’
See: https://www.odata.org/getting-started/basic-tutorial/#filter

Function: ODATA/LANG:$VALUE (url)

Address the raw value of a primitive property.

Example: returns the raw value of property Name of an Airport.
(-> +trip-pin-modify+
(collection "Airports") (id "KSFO")
(property "Name") ($value)

See: https://www.odata.org/getting-started/basic-tutorial/#propertyVal

Function: ODATA/LANG:PROPERTY (url name)

Access the resource property with name NAME.

Function: ODATA/LANG:COLLECTION (url name)

Access the resource collection at NAME.

Function: ODATA/LANG:$SKIP (url skip)

The $skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.

See: https://www.odata.org/getting-started/basic-tutorial/#topskip

Function: ODATA/LANG:PATCH (url data)

Perform a resource PATCH request with DATA to ODATA service at URL.

Function: ODATA/LANG:$TOP (url top)

The $top system query option requests the number of items in the queried collection to be included in the result.

See: https://www.odata.org/getting-started/basic-tutorial/#topskip

Function: ODATA/LANG:SINGLETON (url name)

Access the ODATA singleton with name NAME at URL.
See: https://www.odata.org/getting-started/advanced-tutorial/#querySingleton .

Function: ODATA/LANG:POST (msgraph::url &optional msgraph::data)
Function: ODATA/LANG:$COUNT (url)

The $count system query option allows clients to request a count of the matching resources included with the resources in the response.

Update an already existent link.

A successful PUT request to a single-valued navigation property’s reference resource changes the related entity.

Example: change the Airline of a Flight

(-> +trip-pin-modify+
(collection "People")
(id "russellwhyte")
(path "Trips(0)"
"PlanItems(11)"
"Microsoft.OData.SampleService.Models.TripPin.Flight"
"Airline")
(update-link ‘(("@odata.context" . ,(‘quri:render-uri’ +trip-pin-modify+))
("@odata.id" . "Airlines(’FM’)"))))

Add a link to a related entity.

Relationships from one entity to another are represented as navigation properties.
A successful POST request to a navigation property’s references collection adds a relationship to an existing entity.

Example: add ’vincentcalabrese’ to friends of ’scottketchum’

(-> +trip-pin-modify+
(collection "People") (id "scottketchum")
(property "Friends") ($ref)
(link ‘(("@odata.context" . ,(‘quri:render-uri’ +trip-pin-modify+))
("@odata.id" . "People(’vincentcalabrese’)"))))

Function: ODATA/LANG:$ORDERBY (url property &optional (order :asc))

The $orderby system query option allows clients to request resources in either ascending order using asc or descending order using desc. If asc or desc not specified, then the resources will be ordered in ascending order.

Function: ODATA/LANG:DEL (url)

Perform a resource deletion request at ODATA service at URL.

Function: ODATA/LANG:$EXPAND (url exp)

Add ODATA $expand parameter to URL.

The $expand system query option specifies the related resources to be included in line with retrieved resources.

EXP is the list of things to expand.

Examples:

’("asdf" "foo")) => "asdf,foo"
’("asdf" "foo" ("Bar" "Baz")) => "asdf,foo,Bar/Baz"

See: ‘ODATA-CLIENT::COMPILE-$EXPAND’ .
See: https://www.odata.org/getting-started/basic-tutorial/#expand .

Function: ODATA/LANG:PATH (url &rest path)

Access entity in a PATH.

Example:

(-> +trip-pin-modify+
(collection "People")
(id "russellwhyte")
(path "Trips(0)"
"PlanItems(11)"
"Microsoft.OData.SampleService.Models.TripPin.Flight"
"Airline"))

Function: ODATA/LANG:CREATE (url data)

Perform a resource creation request with DATA at ODATA service at URL.

Function: ODATA/LANG:$SELECT (url exp)

Adds ODATA $select parameter to URL.

The $select system query option allows the clients to requests a limited set of properties for each entity.

EXP can be either a string or a list of strings.
Elements of EXP are just separated by comma.

Examples:
(compile-$select "name") => "foo"
(compile-$select ’("name" "surname")) => "name,surname"

See: ‘ODATA-CLIENT::COMPILE-$SELECT’
See: https://www.odata.org/getting-started/basic-tutorial/#select

Function: ODATA/LANG:UPDATE (url data)

Perform a resource update (PUT request) with DATA to ODATA service at URL.

Function: ODATA/LANG:ID (url id)

Get ODATA resource id.

Function: ODATA/LANG:FCALL (url name &rest args)

Call the ODATA action with name NAME and arguments ARGS.

Actions are operations exposed by an OData service that MAY have side effects when invoked. Actions MAY return data but MUST ‘NOT’ be further composed with additional path segments.

See: https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_Actions

Function: ODATA/LANG:$SEARCH (url exp)

The $search system query option restricts the result to include only those entities matching the specified search expression.

See: https://www.odata.org/getting-started/basic-tutorial/#search

Function: ODATA/LANG:$REF (url)

A successful POST request to a navigation property’s references collection adds a relationship to an existing entity.


Previous: , Up: API   [Contents][Index]

5.3 ODATA/ENTITY package

PACKAGE: ODATA/ENTITY

External definitions

Macros

Macro: ODATA/ENTITY:WITH-PROPERTIES (properties entity &body body)

Bind PROPERTIES in ENTITY.

Example:

(with-properties (user-name) user
(print user-name))

Generic functions

Generic-Function: ODATA/ENTITY:ODATA-CONTEXT (sb-pcl::object)
Generic-Function: ODATA/ENTITY:ODATA-ID (sb-pcl::object)
Generic-Function: ODATA/ENTITY:ENTITY-SET-ELEMENTS (sb-pcl::object)
Generic-Function: ODATA/ENTITY:ODATA-ETAG (sb-pcl::object)

Functions

Function: ODATA/ENTITY:READ-ODATA-RESPONSE (data)

Unserializes an ODATA request response.

Function: ODATA/ENTITY:FIND-SCHEMA (schema-url)

Return cached schema at SCHEMA-URL, or fetch and add to the cache.

Function: ODATA/ENTITY:FETCH-SCHEMA (schema-url)

Fetch and parse and ODATA schema from SCHEMA-URL.

Function: ODATA/ENTITY:GET-PROPERTY (entity property-name)

Get value of property PROPERTY-NAME in ENTITY.

Classes

Class: ODATA/ENTITY:ODATA-ENTITY-SET

And ODATA entity set.

Class precedence list: odata-entity-set, standard-object, t

Class: ODATA/ENTITY:ODATA-ENTITY

An ODATA entity.

Class precedence list: odata-entity, standard-object, t


Previous: , Up: Top   [Contents][Index]

6 Index

Jump to:   C   O  
Index Entry  Section

C
cl-odata-client: Top

O
odata-client: Top

Jump to:   C   O  
Jump to:   *  
O  
Index Entry  Section

*
*ACCESS-TOKEN*: ODATA-CLIENT package
*SERVICE-ROOT*: ODATA-CLIENT package

O
ODATA-CLIENT:*ACCESS-TOKEN*: ODATA-CLIENT package
ODATA-CLIENT:*SERVICE-ROOT*: ODATA-CLIENT package

Jump to:   *  
O  
Jump to:   O  
Index Entry  Section

O
ODATA-CLIENT:ODATA-GET: ODATA-CLIENT package
ODATA-CLIENT:ODATA-GET: ODATA-CLIENT package
ODATA-CLIENT:ODATA-GET*: ODATA-CLIENT package
ODATA-CLIENT:ODATA-GET*: ODATA-CLIENT package
ODATA-CLIENT:ODATA-PATCH: ODATA-CLIENT package
ODATA-CLIENT:ODATA-PATCH: ODATA-CLIENT package
ODATA-CLIENT:ODATA-POST: ODATA-CLIENT package
ODATA-CLIENT:ODATA-POST: ODATA-CLIENT package
ODATA-CLIENT:ODATA-PUT: ODATA-CLIENT package
ODATA-CLIENT:ODATA-PUT: ODATA-CLIENT package
ODATA-CLIENT:WITH-SERVICE-ROOT: ODATA-CLIENT package
ODATA-CLIENT:WITH-SERVICE-ROOT: ODATA-CLIENT package
ODATA/ENTITY:ENTITY-SET-ELEMENTS: ODATA/ENTITY package
ODATA/ENTITY:ENTITY-SET-ELEMENTS: ODATA/ENTITY package
ODATA/ENTITY:FETCH-SCHEMA: ODATA/ENTITY package
ODATA/ENTITY:FETCH-SCHEMA: ODATA/ENTITY package
ODATA/ENTITY:FIND-SCHEMA: ODATA/ENTITY package
ODATA/ENTITY:FIND-SCHEMA: ODATA/ENTITY package
ODATA/ENTITY:GET-PROPERTY: ODATA/ENTITY package
ODATA/ENTITY:GET-PROPERTY: ODATA/ENTITY package
ODATA/ENTITY:ODATA-CONTEXT: ODATA/ENTITY package
ODATA/ENTITY:ODATA-CONTEXT: ODATA/ENTITY package
ODATA/ENTITY:ODATA-EDIT-LINK: ODATA/ENTITY package
ODATA/ENTITY:ODATA-EDIT-LINK: ODATA/ENTITY package
ODATA/ENTITY:ODATA-ETAG: ODATA/ENTITY package
ODATA/ENTITY:ODATA-ETAG: ODATA/ENTITY package
ODATA/ENTITY:ODATA-ID: ODATA/ENTITY package
ODATA/ENTITY:ODATA-ID: ODATA/ENTITY package
ODATA/ENTITY:ODATA-NEXT-LINK: ODATA/ENTITY package
ODATA/ENTITY:ODATA-NEXT-LINK: ODATA/ENTITY package
ODATA/ENTITY:READ-ODATA-RESPONSE: ODATA/ENTITY package
ODATA/ENTITY:READ-ODATA-RESPONSE: ODATA/ENTITY package
ODATA/ENTITY:WITH-PROPERTIES: ODATA/ENTITY package
ODATA/ENTITY:WITH-PROPERTIES: ODATA/ENTITY package
ODATA/LANG:$COUNT: ODATA/LANG package
ODATA/LANG:$COUNT: ODATA/LANG package
ODATA/LANG:$EXPAND: ODATA/LANG package
ODATA/LANG:$EXPAND: ODATA/LANG package
ODATA/LANG:$FILTER: ODATA/LANG package
ODATA/LANG:$FILTER: ODATA/LANG package
ODATA/LANG:$ORDERBY: ODATA/LANG package
ODATA/LANG:$ORDERBY: ODATA/LANG package
ODATA/LANG:$REF: ODATA/LANG package
ODATA/LANG:$REF: ODATA/LANG package
ODATA/LANG:$SEARCH: ODATA/LANG package
ODATA/LANG:$SEARCH: ODATA/LANG package
ODATA/LANG:$SELECT: ODATA/LANG package
ODATA/LANG:$SELECT: ODATA/LANG package
ODATA/LANG:$SKIP: ODATA/LANG package
ODATA/LANG:$SKIP: ODATA/LANG package
ODATA/LANG:$TOP: ODATA/LANG package
ODATA/LANG:$TOP: ODATA/LANG package
ODATA/LANG:$VALUE: ODATA/LANG package
ODATA/LANG:$VALUE: ODATA/LANG package
ODATA/LANG:COLLECTION: ODATA/LANG package
ODATA/LANG:COLLECTION: ODATA/LANG package
ODATA/LANG:CREATE: ODATA/LANG package
ODATA/LANG:CREATE: ODATA/LANG package
ODATA/LANG:DEL: ODATA/LANG package
ODATA/LANG:DEL: ODATA/LANG package
ODATA/LANG:FCALL: ODATA/LANG package
ODATA/LANG:FCALL: ODATA/LANG package
ODATA/LANG:FETCH: ODATA/LANG package
ODATA/LANG:FETCH: ODATA/LANG package
ODATA/LANG:ID: ODATA/LANG package
ODATA/LANG:ID: ODATA/LANG package
ODATA/LANG:LINK: ODATA/LANG package
ODATA/LANG:LINK: ODATA/LANG package
ODATA/LANG:PATCH: ODATA/LANG package
ODATA/LANG:PATCH: ODATA/LANG package
ODATA/LANG:PATH: ODATA/LANG package
ODATA/LANG:PATH: ODATA/LANG package
ODATA/LANG:POST: ODATA/LANG package
ODATA/LANG:POST: ODATA/LANG package
ODATA/LANG:PROPERTY: ODATA/LANG package
ODATA/LANG:PROPERTY: ODATA/LANG package
ODATA/LANG:SINGLETON: ODATA/LANG package
ODATA/LANG:SINGLETON: ODATA/LANG package
ODATA/LANG:UPDATE: ODATA/LANG package
ODATA/LANG:UPDATE: ODATA/LANG package
ODATA/LANG:UPDATE-LINK: ODATA/LANG package
ODATA/LANG:UPDATE-LINK: ODATA/LANG package

Jump to:   O