github.com/ncodes/nomad@v0.5.7-0.20170403112158-97adf4a74fb3/website/source/docs/http/client-fs.html.md (about)

     1  ---
     2  layout: "http"
     3  page_title: "HTTP API: /v1/client/fs"
     4  sidebar_current: "docs-http-client-fs"
     5  description: |-
     6    The '/v1/client/fs` endpoints are used to read the contents of an allocation
     7    directory.
     8  ---
     9  
    10  # /v1/client/fs
    11  
    12  The client `fs` endpoints are used to read the contents of files and
    13  directories inside an allocation directory. The API endpoints are hosted by the
    14  Nomad client and requests have to be made to the Client where the particular
    15  allocation was placed.
    16  
    17  ## GET
    18  
    19  <dl>
    20    <dt>Description</dt>
    21    <dd>
    22       Read contents of a file in an allocation directory.
    23    </dd>
    24  
    25    <dt>Method</dt>
    26    <dd>GET</dd>
    27  
    28    <dt>URL</dt>
    29    <dd>`/v1/client/fs/cat/<Allocation-ID>`</dd>
    30  
    31    <dt>Parameters</dt>
    32    <dd>
    33      <ul>
    34        <li>
    35          <span class="param">path</span>
    36          <span class="param-flags">required</span>
    37           The path relative to the root of the allocation directory. It 
    38           defaults to `/`
    39        </li>
    40      </ul>
    41    </dd>
    42  
    43    <dt>Returns</dt>
    44    <dd>
    45  
    46      ```
    47  ...
    48  07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1
    49  07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379
    50  ...
    51      ```
    52  
    53    </dd>
    54  
    55  </dl>
    56  
    57  <dl>
    58    <dt>Description</dt>
    59    <dd>
    60       Read contents of a file in an allocation directory at a particular offset.
    61    </dd>
    62  
    63    <dt>Method</dt>
    64    <dd>GET</dd>
    65  
    66    <dt>URL</dt>
    67    <dd>`/v1/client/fs/readat/<Allocation-ID>`</dd>
    68  
    69    <dt>Parameters</dt>
    70    <dd>
    71      <ul>
    72        <li>
    73          <span class="param">path</span>
    74          <span class="param-flags">required</span>
    75           The path relative to the root of the allocation directory. It 
    76           defaults to `/`
    77        </li>
    78      </ul>
    79      <ul>
    80        <li>
    81          <span class="param">offset</span>
    82          <span class="param-flags">required</span>
    83          The byte offset from where content is going to be read.
    84        </li>
    85      </ul>
    86      <ul>
    87        <li>
    88          <span class="param">limit</span>
    89          <span class="param-flags">required</span>
    90          The number of bytes to read from the offset.
    91        </li>
    92      </ul>
    93  
    94    </dd>
    95  
    96    <dt>Returns</dt>
    97    <dd>
    98  
    99      ```
   100  ...
   101  07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1
   102  07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379
   103  ...
   104      ```
   105  
   106    </dd>
   107  
   108  </dl>
   109  
   110  
   111  <dl>
   112    <dt>Description</dt>
   113    <dd>
   114       Stream contents of a file in an allocation directory.
   115    </dd>
   116  
   117    <dt>Method</dt>
   118    <dd>GET</dd>
   119  
   120    <dt>URL</dt>
   121    <dd>`/v1/client/fs/stream/<Allocation-ID>`</dd>
   122  
   123    <dt>Parameters</dt>
   124    <dd>
   125      <ul>
   126        <li>
   127          <span class="param">path</span>
   128          <span class="param-flags">required</span>
   129           The path relative to the root of the allocation directory. It 
   130           defaults to `/`
   131        </li>
   132        <li>
   133          <span class="param">offset</span>
   134           The offset to start streaming from. Defaults to 0.
   135        </li>
   136        <li>
   137          <span class="param">origin</span>
   138          Origin can be either "start" or "end" and applies the offset relative to
   139          either the start or end of the file respectively. Defaults to "start".
   140        </li>
   141      </ul>
   142    </dd>
   143  
   144    <dt>Returns</dt>
   145    <dd>
   146  
   147      ```
   148  ...
   149      {
   150          "File":"alloc/logs/redis.stdout.0",
   151          "Offset":3604480
   152          "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..."
   153      }
   154      {
   155          "File":"alloc/logs/redis.stdout.0",
   156          "FileEvent": "file deleted"
   157      }
   158      ```
   159  
   160    </dd>
   161  
   162  
   163    <dt>Field Reference</dt>
   164    <dd>
   165      The return value is a stream of frames. These frames contain the following
   166      fields:
   167  
   168      <ul>
   169        <li>
   170          <span class="param">Data</span>
   171          A base64 encoding of the bytes being streamed.
   172        </li>
   173        <li>
   174          <span class="param">FileEvent</span>
   175          An event that could cause a change in the streams position. The possible
   176          values are "file deleted" and "file truncated".
   177        </li>
   178        <li>
   179          <span class="param">Offset</span>
   180          Offset is the offset into the stream.
   181        </li>
   182        <li>
   183          <span class="param">File</span>
   184          The name of the file being streamed.
   185        </li>
   186      </ul>
   187    </dd>
   188  </dl>
   189  
   190  <a id="logs"></a>
   191  
   192  <dl>
   193    <dt>Description</dt>
   194    <dd>
   195       Stream a task's stdout/stderr logs.
   196    </dd>
   197  
   198    <dt>Method</dt>
   199    <dd>GET</dd>
   200  
   201    <dt>URL</dt>
   202    <dd>`/v1/client/fs/logs/<Allocation-ID>`</dd>
   203  
   204    <dt>Parameters</dt>
   205    <dd>
   206      <ul>
   207        <li>
   208          <span class="param">task</span>
   209          <span class="param-flags">required</span>
   210          The name of the task inside the allocation to stream logs from.
   211        </li>
   212        <li>
   213          <span class="param">follow</span>
   214          <span class="param-flags">required</span>
   215           A boolean of whether to follow logs.
   216        </li>
   217        <li>
   218          <span class="param">type</span>
   219           Either, "stdout" or "stderr", defaults to "stdout" if omitted.
   220        </li>
   221        <li>
   222          <span class="param">offset</span>
   223           The offset to start streaming from. Defaults to 0.
   224        </li>
   225        <li>
   226          <span class="param">origin</span>
   227          Origin can be either "start" or "end" and applies the offset relative to
   228          either the start or end of the logs respectively. Defaults to "start".
   229        </li>
   230        <li>
   231          <span class="param">plain</span>
   232          A boolean of whether to return just the plain text without framing.
   233          This can be usef when viewing logs in a browser.
   234        </li>
   235      </ul>
   236    </dd>
   237  
   238    <dt>Returns</dt>
   239    <dd>
   240  
   241      ```
   242  ...
   243      {
   244          "File":"alloc/logs/redis.stdout.0",
   245          "Offset":3604480
   246          "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..."
   247      }
   248      {
   249          "File":"alloc/logs/redis.stdout.0",
   250          "FileEvent": "file deleted"
   251      }
   252      ```
   253  
   254    </dd>
   255  
   256  
   257    <dt>Field Reference</dt>
   258    <dd>
   259      The return value is a stream of frames. These frames contain the following
   260      fields:
   261  
   262      <ul>
   263        <li>
   264          <span class="param">Data</span>
   265          A base64 encoding of the bytes being streamed.
   266        </li>
   267        <li>
   268          <span class="param">FileEvent</span>
   269          An event that could cause a change in the streams position. The possible
   270          values are "file deleted" and "file truncated".
   271        </li>
   272        <li>
   273          <span class="param">Offset</span>
   274          Offset is the offset into the stream.
   275        </li>
   276        <li>
   277          <span class="param">File</span>
   278          The name of the file being streamed.
   279        </li>
   280      </ul>
   281    </dd>
   282  </dl>
   283  
   284  <dl>
   285    <dt>Description</dt>
   286    <dd>
   287       List files in an allocation directory.
   288    </dd>
   289  
   290    <dt>Method</dt>
   291    <dd>GET</dd>
   292  
   293    <dt>URL</dt>
   294    <dd>`/v1/client/fs/ls/<Allocation-ID>`</dd>
   295  
   296    <dt>Parameters</dt>
   297    <dd>
   298      <ul>
   299        <li>
   300          <span class="param">path</span>
   301          <span class="param-flags">required</span>
   302          The path relative to the root of the allocation directory. It 
   303          defaults to `/`, the root of the allocation directory.
   304        </li>
   305      </ul>
   306    </dd>
   307  
   308    <dt>Returns</dt>
   309    <dd>
   310  
   311      ```javascript
   312      [
   313        {
   314          "Name": "alloc",
   315          "IsDir": true,
   316          "Size": 4096,
   317          "FileMode": "drwxrwxr-x",
   318          "ModTime": "2016-03-15T15:40:00.414236712-07:00"
   319        },
   320        {
   321          "Name": "redis",
   322          "IsDir": true,
   323          "Size": 4096,
   324          "FileMode": "drwxrwxr-x",
   325          "ModTime": "2016-03-15T15:40:56.810238153-07:00"
   326        }
   327      ]
   328      ```
   329  
   330    </dd>
   331  </dl>
   332  
   333  <dl>
   334    <dt>Description</dt>
   335    <dd>
   336       Stat a file in an allocation directory.
   337    </dd>
   338  
   339    <dt>Method</dt>
   340    <dd>GET</dd>
   341  
   342    <dt>URL</dt>
   343    <dd>`/v1/client/fs/stat/<Allocation-ID>`</dd>
   344  
   345    <dt>Parameters</dt>
   346    <dd>
   347      <ul>
   348        <li>
   349          <span class="param">path</span>
   350          <span class="param-flags">required</span>
   351          The path of the file relative to the root of the allocation directory.
   352        </li>
   353      </ul>
   354    </dd>
   355  
   356    <dt>Returns</dt>
   357    <dd>
   358  
   359      ```javascript
   360      {
   361        "Name": "redis-syslog-collector.out",
   362        "IsDir": false,
   363        "Size": 96,
   364        "FileMode": "-rw-rw-r--",
   365        "ModTime": "2016-03-15T15:40:56.822238153-07:00"
   366      }
   367      ```
   368  
   369    </dd>
   370  </dl>