github.com/imran-kn/cilium-fork@v1.6.9/Documentation/api.rst (about)

     1  .. only:: not (epub or latex or html)
     2  
     3      WARNING: You are looking at unreleased Cilium documentation.
     4      Please use the official rendered version released here:
     5      http://docs.cilium.io
     6  
     7  .. _api_ref:
     8  
     9  #############
    10  API Reference
    11  #############
    12  
    13  ************
    14  Introduction
    15  ************
    16  
    17  The Cilium API is JSON based and provided by the ``cilium-agent``. The purpose
    18  of the API is to provide visibility and control over an individual agent
    19  instance. In general, all API calls affect only the resources managed by the
    20  individual ``cilium-agent`` serving the API. A few selected API calls such as
    21  the security identity resolution provides cluster wide visibility. Such API
    22  calls are marked specifically. Unless noted otherwise, API calls will only affect
    23  local agent resources.
    24  
    25  *********************
    26  How to access the API
    27  *********************
    28  
    29  CLI Client
    30  ==========
    31  
    32  The easiest way to access the API is via the ``cilium`` CLI client. ``cilium``
    33  will automatically locate the API of the agent running on the same node and
    34  access it. However, using the ``-H`` or ``--host`` flag, the ``cilium`` client
    35  can be pointed to an arbitrary API address.
    36  
    37  Example
    38  -------
    39  
    40  .. code:: bash
    41  
    42      $ cilium -H unix:///var/run/cilium/cilium.sock
    43      [...]
    44  
    45  
    46  Golang Package
    47  ==============
    48  
    49  The following Go packages can be used to access the API:
    50  
    51  +---------------------+---------------------------------------------------------------+
    52  | Package             | Description                                                   |
    53  +---------------------+---------------------------------------------------------------+
    54  | `pkg/client`_       | Main client API abstraction                                   |
    55  +---------------------+---------------------------------------------------------------+
    56  | `api/v1/models`_    | API resource data type models                                 |
    57  +---------------------+---------------------------------------------------------------+
    58  
    59  Example
    60  -------
    61  
    62  The full example can be found in the `cilium/client-example`_ repository.
    63  
    64  .. code:: go
    65  
    66      import (
    67              "fmt"
    68  
    69              "github.com/cilium/cilium/pkg/client"
    70      )
    71  
    72      func main() {
    73              c, err := client.NewDefaultClient()
    74              if err != nil {
    75                      ...
    76              }
    77  
    78              endpoints, err := c.EndpointList()
    79              if err != nil {
    80                      ...
    81              }
    82  
    83              for _, ep := range endpoints {
    84                      fmt.Printf("%8d %14s %16s %32s\n", ep.ID, ep.ContainerName, ep.Addressing.IPV4, ep.Addressing.IPV6)
    85              }
    86  
    87  ************************
    88  Compatibility Guarantees
    89  ************************
    90  
    91  Cilium API is stable as of version 1.0, backward compatibility will be upheld
    92  for whole lifecycle of Cilium 1.x.
    93  
    94  *************
    95  API Reference
    96  *************
    97  
    98  .. openapi:: ../api/v1/openapi.yaml
    99  
   100  .. _pkg/client: https://godoc.org/github.com/cilium/cilium/pkg/client
   101  .. _api/v1/models: https://godoc.org/github.com/cilium/cilium/api/v1/models
   102  .. _cilium/client-example: https://github.com/cilium/client-example