A pact between GDS API Adapters and Asset Manager

Requests from GDS API Adapters to Asset Manager

Interactions

Upon receiving a create asset request from GDS API Adapters, with

{
  "method": "post",
  "path": "/assets",
  "headers": {
    "Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryjFAA2WBg0ki601kd"
  },
  "body": "------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[file]\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, world!\n\r\n------RubyFormBoundaryjFAA2WBg0ki601kd--\r\n"
}

Asset Manager will respond with:

{
  "status": 201,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "file_url": "http://static.dev.gov.uk/media/62b418d7c7d6b700ce9fa93d/hello.txt",
    "name": "hello.txt",
    "content_type": "text/plain; charset=utf-8",
    "size": 14,
    "state": "unscanned",
    "draft": false,
    "deleted": false
  }
}

Upon receiving a create whitehall asset request from GDS API Adapters, with

{
  "method": "post",
  "path": "/whitehall_assets",
  "headers": {
    "Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryjFAA2WBg0ki601kd"
  },
  "body": "------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[file]\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, world!\n\r\n------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[legacy_url_path]\"\r\n\r\n/government/uploads/some-edition/hello.txt\r\n------RubyFormBoundaryjFAA2WBg0ki601kd--\r\n"
}

Asset Manager will respond with:

{
  "status": 201,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "file_url": "http://static.dev.gov.uk/government/uploads/some-edition/hello.txt",
    "name": "hello.txt",
    "content_type": "text/plain; charset=utf-8",
    "size": 14,
    "state": "unscanned",
    "draft": false,
    "deleted": false
  }
}

Given a whitehall asset exists with legacy url path /government/uploads/some-edition/hello.txt and id 4dca570c2975bc0d6d437491, upon receiving a delete asset request from GDS API Adapters, with

{
  "method": "delete",
  "path": "/assets/4dca570c2975bc0d6d437491"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "uploaded",
    "file_url": "http://static.dev.gov.uk/government/uploads/some-edition/hello.txt",
    "draft": false,
    "deleted": true
  }
}

Given an asset exists with identifier 4dca570c2975bc0d6d437491, upon receiving a delete asset request from GDS API Adapters, with

{
  "method": "delete",
  "path": "/assets/4dca570c2975bc0d6d437491"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "uploaded",
    "file_url": "http://static.dev.gov.uk/media/4dca570c2975bc0d6d437491/asset.png",
    "draft": false,
    "deleted": true
  }
}

Given an asset exists with identifier 4dca570c2975bc0d6d437491, upon receiving a get asset request from GDS API Adapters, with

{
  "method": "get",
  "path": "/assets/4dca570c2975bc0d6d437491"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "uploaded",
    "file_url": "http://static.dev.gov.uk/media/4dca570c2975bc0d6d437491/asset.png",
    "draft": false,
    "deleted": false
  }
}

Upon receiving a get asset request from GDS API Adapters, with

{
  "method": "get",
  "path": "/assets/4dca570c2975bc0d6d437491"
}

Asset Manager will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given a whitehall asset exists with legacy url path /government/uploads/some-edition/hello.txt and id 4dca570c2975bc0d6d437491, upon receiving a get whitehall asset request from GDS API Adapters, with

{
  "method": "get",
  "path": "/whitehall_assets//government/uploads/some-edition/hello.txt"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "uploaded",
    "file_url": "http://static.dev.gov.uk/government/uploads/some-edition/hello.txt",
    "draft": false,
    "deleted": false
  }
}

Given a soft deleted asset exists with identifier 4dca570c2975bc0d6d437491, upon receiving a restore asset request from GDS API Adapters, with

{
  "method": "post",
  "path": "/assets/4dca570c2975bc0d6d437491/restore"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "unscanned",
    "file_url": "http://static.dev.gov.uk/media/4dca570c2975bc0d6d437491/asset.png",
    "draft": false,
    "deleted": false
  }
}

Given a soft deleted whitehall asset exists with legacy url path /government/uploads/some-edition/hello.txt and id 4dca570c2975bc0d6d437491, upon receiving a restore asset request from GDS API Adapters, with

{
  "method": "post",
  "path": "/assets/4dca570c2975bc0d6d437491/restore"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "name": "asset.png",
    "content_type": "image/png",
    "size": 57705,
    "state": "uploaded",
    "file_url": "http://static.dev.gov.uk/government/uploads/some-edition/hello.txt",
    "draft": false,
    "deleted": false
  }
}

Given a whitehall asset exists with legacy url path /government/uploads/some-edition/hello.txt and id 4dca570c2975bc0d6d437491, upon receiving an update asset request from GDS API Adapters, with

{
  "method": "put",
  "path": "/assets/4dca570c2975bc0d6d437491",
  "headers": {
    "Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryjFAA2WBg0ki601kd"
  },
  "body": "------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[file]\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, world!\n\r\n------RubyFormBoundaryjFAA2WBg0ki601kd--\r\n"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "file_url": "http://static.dev.gov.uk/government/uploads/some-edition/hello.txt",
    "name": "hello.txt",
    "content_type": "text/plain; charset=utf-8",
    "size": 14,
    "state": "unscanned",
    "draft": false,
    "deleted": false
  }
}

Given an asset exists with identifier 4dca570c2975bc0d6d437491, upon receiving an update asset request from GDS API Adapters, with

{
  "method": "put",
  "path": "/assets/4dca570c2975bc0d6d437491",
  "headers": {
    "Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryjFAA2WBg0ki601kd"
  },
  "body": "------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[file]\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, world!\n\r\n------RubyFormBoundaryjFAA2WBg0ki601kd--\r\n"
}

Asset Manager will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "id": "http://example.org/assets/4dca570c2975bc0d6d437491",
    "file_url": "http://static.dev.gov.uk/media/4dca570c2975bc0d6d437491/hello.txt",
    "name": "hello.txt",
    "content_type": "text/plain; charset=utf-8",
    "size": 14,
    "state": "unscanned",
    "draft": false,
    "deleted": false
  }
}

Given a soft deleted asset exists with identifier 4dca570c2975bc0d6d437491, upon receiving an update asset request from GDS API Adapters, with

{
  "method": "put",
  "path": "/assets/4dca570c2975bc0d6d437491",
  "headers": {
    "Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryjFAA2WBg0ki601kd"
  },
  "body": "------RubyFormBoundaryjFAA2WBg0ki601kd\r\nContent-Disposition: form-data; name=\"asset[file]\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, world!\n\r\n------RubyFormBoundaryjFAA2WBg0ki601kd--\r\n"
}

Asset Manager will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}