Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: API Client can list domains via GET /v3/domains (with filtering by name) #177

Closed
davewalter opened this issue Sep 28, 2021 · 0 comments

Comments

@davewalter
Copy link
Member

Blockers/Dependencies

Background

As a client of the API shim
I want to be able to list Domains
So that I can see all the domains that I have access to

As a client of the API shim
I want to be able to filter the list Domains by domain name
So that I can see a subset of the domains that I have access to

Acceptance Scenarios

GIVEN I have the API shim running locally
THEN I can make perform the following scenarios


Happy Path (when at least one domain exists)

GIVEN I have applied a CFDomain CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following request

curl "https://api.example.org/v3/domains" \
  -X GET \
  -H "Authorization: bearer <some-placeholder-token>" \

THEN I get a response that looks like the following

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

{
  "pagination": {
    "total_results": 1,
    "total_pages": 1,
    "first": {
      "href": "https://api.example.org/v3/domains?page=1"
    },
    "last": {
      "href": "https://api.example.org/v3/domains?page=1"
    },
    "next": null,
    "previous": null
  },
  "resources": [
    {
      "guid": "5b5032ab-7fc8-4da5-b853-821fd1879201",
      "created_at": "2019-03-08T01:06:19Z",
      "updated_at": "2019-03-08T01:06:19Z",
      "name": "cf-apps.io",
      "internal": false,
      "router_group": null,
      "supported_protocols": ["http"],
      "metadata": {
        "labels": {},
        "annotations": {}
      },
      "relationships": {
        "organization": {
          "data": null
        },
        "shared_organizations": {
          "data": []
        }
      },
      "links": {
        "self": {
          "href": "https://api.example.org/v3/domains/5b5032ab-7fc8-4da5-b853-821fd1879201"
        },
        "route_reservations": {
          "href": "https://api.example.org/v3/domains/5b5032ab-7fc8-4da5-b853-821fd1879201/route_reservations"
        },
        "router_group": null
      }
    },
  ]
}

Happy Path (when no domains exist)

GIVEN that no CFDomain resources exist
WHEN I make the following request

curl "https://api.example.org/v3/domains" \
  -X GET \
  -H "Authorization: bearer <some-placeholder-token>" \

THEN I get a response that looks like the following

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

{
  "pagination": {
    "total_results": 1,
    "total_pages": 1,
    "first": {
      "href": "https://api.example.org/v3/domains?page=1"
    },
    "last": {
      "href": "https://api.example.org/v3/domains?page=1"
    },
    "next": null,
    "previous": null
  },
  "resources": []
}

Happy Path (when at least one matching domain exists)

GIVEN I have applied a CFDomain CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following request

curl "https://api.example.org/v3/domains?names=cf-apps.io" \
  -X GET \
  -H "Authorization: bearer <some-placeholder-token>" \

THEN I get a response that looks like the following

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

{
  "pagination": {
    "total_results": 1,
    "total_pages": 1,
    "first": {
      "href": "https://api.example.org/v3/domains?page=1&names=cf-apps.io"
    },
    "last": {
      "href": "https://api.example.org/v3/domains?page=1&names=cf-apps.io"
    },
    "next": null,
    "previous": null
  },
  "resources": [
    {
      "guid": "5b5032ab-7fc8-4da5-b853-821fd1879201",
      "created_at": "2019-03-08T01:06:19Z",
      "updated_at": "2019-03-08T01:06:19Z",
      "name": "cf-apps.io",
      "internal": false,
      "router_group": null,
      "supported_protocols": ["http"],
      "metadata": {
        "labels": {},
        "annotations": {}
      },
      "relationships": {
        "organization": {
          "data": null
        },
        "shared_organizations": {
          "data": []
        }
      },
      "links": {
        "self": {
          "href": "https://api.example.org/v3/domains/5b5032ab-7fc8-4da5-b853-821fd1879201"
        },
        "route_reservations": {
          "href": "https://api.example.org/v3/domains/5b5032ab-7fc8-4da5-b853-821fd1879201/route_reservations"
        },
        "router_group": null
      }
    },
  ]
}

Happy Path (when no matching domains exist)

GIVEN I have applied a CFDomain CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following request

curl "https://api.example.org/v3/domains?names=example.org" \
  -X GET \
  -H "Authorization: bearer <some-placeholder-token>" \

THEN I get a response that looks like the following

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

{
  "pagination": {
    "total_results": 1,
    "total_pages": 1,
    "first": {
      "href": "https://api.example.org/v3/domains?page=1&names=example.org"
    },
    "last": {
      "href": "https://api.example.org/v3/domains?page=1&names=example.org"
    },
    "next": null,
    "previous": null
  },
  "resources": []
}

Sad Path (invalid query parameter)

WHEN I make the following request

curl "https://api.example.org/v3/domains?foo=bar" \
  -X GET \
  -H "Authorization: bearer <some-placeholder-token>" \

THEN I get a response that looks like the following

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "errors": [
    {
      "detail": "The query parameter is invalid: Valid parameters are: 'names'",
      "title": "CF-BadQueryParameter",
      "code": 10005
    }
  ]
}

Documentation

Document this endpoint in our API docs

Dev Notes

@davewalter davewalter changed the title [Feature]: API Client can list routes via GET /v3/domains?names=<domain-name> [Feature]: API Client can list routes via GET /v3/domains (with filtering by name) Sep 29, 2021
@acosta11 acosta11 changed the title [Feature]: API Client can list routes via GET /v3/domains (with filtering by name) [Feature]: API Client can list domains via GET /v3/domains (with filtering by name) Oct 4, 2021
@Birdrock Birdrock transferred this issue from cloudfoundry/cf-k8s-api Nov 2, 2021
tcdowney added a commit that referenced this issue Nov 16, 2021
- Added additional string trimming
- Correctly return an empty list of Names when the param is omitted
- Addresses #177

Authored-by: Tim Downey <tdowney@vmware.com>
tcdowney added a commit that referenced this issue Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant