Skip to content

CreatedAt and UpdatedAt in API responses should be valid timstampsΒ #4259

@danail-branekov

Description

@danail-branekov

Background

Currently, created_at and updated_at fields from API reponse objects are plain strings (for example, the app response). While that is fine for the CF cli, programmatic clients, such as go-cfclient, do not accept plain strings

Acceptance

GIVEN I have pushed some apps
WHEN I list apps via

curl "https://api.example.org/v3/apps" \
  -X GET \
  -H "Authorization: bearer [token]"

THEN I get a reponse with valid created_at and updated_at timestamps

HTTP/1.1 200 OK
Content-Type: application/json

  {
    "pagination": {
      ...
    },
    "resources": [
      {
        "guid": "1cb006ee-fb05-47e1-b541-c34179ddc446",
        "name": "my_app",
        "state": "STARTED",
        "created_at": "2016-03-17T21:41:30Z",
        "updated_at": "2016-03-18T11:32:30Z",
        ...
      },
      ...
    ]
  }

Dev notes

  • We are currently encoding the response body with a JSON encoder that has its escapeHTML option enabled. While this is convinient to escape special characters in the resource links, we believe that that escaping is messing up with timestamps
  • The easiest way to solve this seems to simply change the type of CreatedAt and UpdatedAt fields to time.Time
  • We need to apply that pattern to all the response types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    πŸ‡ͺπŸ‡Ί To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions