Skip to content

Commit

Permalink
clean up namespace terminology for spec and test files, convert to ke…
Browse files Browse the repository at this point in the history
…yspace (#1426)
  • Loading branch information
Yuqi-Du authored Sep 16, 2024
1 parent 65c424d commit 292ff5d
Show file tree
Hide file tree
Showing 41 changed files with 728 additions and 728 deletions.
30 changes: 15 additions & 15 deletions docs/dataapi-network-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ See the [Data API Query Specification](dataapi-spec.md) for details of data mode
- [Conventions](#conventions)
- [Error handling](#error-handling)
- [Endpoints](#endpoints)
- [Namespace endpoint](#namespace-endpoint)
- [Namespace endpoint errors](#errors)
- [Keyspace endpoint](#keyspace-endpoint)
- [Keyspace endpoint errors](#errors)
- [Collection endpoint](#collection-endpoint)
- [Authentication and Authorization](#authentication-and-authorization)

Expand Down Expand Up @@ -78,7 +78,7 @@ concepts that are used to describe this process are:

- **Endpoints:** The URL address for clients to send request messages.
There are two types of endpoints which accept different messages:
namespace and collection endpoints.
keyspace and collection endpoints.
- **Request Message:** A message from the client to the server
requesting the server take some action, such as inserting or finding
documents.
Expand Down Expand Up @@ -145,8 +145,8 @@ encoded in the response message. To avoid doubt these errors are called

The HTTP API provides two types of endpoints:

- Namespace Endpoint: used to send commands which apply to the whole
Namespace, such as listing all the Collections.
- Keyspace Endpoint: used to send commands which apply to the whole
Keyspace, such as listing all the Collections.
- Collection Endpoint: used to send commands which apply to a single
Collection, such as finding users by age.

Expand All @@ -163,28 +163,28 @@ Both endpoints follow these rules:
4. Requests **must** specify the
`Accept:application/json; charset=UTF-8` header

### Namespace Endpoint
### Keyspace Endpoint

The Namespace Endpoint has the form:
The Keyspace Endpoint has the form:

*Syntax:*

```bnf
<namespace-endpoint> ::= <server-address>/<namespace-name>
<keyspace-endpoint> ::= <server-address>/<keyspace-name>
```

`<server-address>` is a Server URI using HTTP (S), scheme://host/path

`<namespace-name>` must begin with an alpha-numeric character and
`<keyspace-name>` must begin with an alpha-numeric character and
can only contain alpha-numeric characters and underscores.

*Sample:*

`https://stargate.mycompany.com/my-namespace`
`https://stargate.mycompany.com/my-keyspace`

#### Namespace endpoint errors
#### Keyspace endpoint errors

Requests sent to a Namespace that was not previously created via administration tools results in a **TODO** soft error.
Requests sent to a Keyspace that was not previously created via administration tools results in a **TODO** soft error.

### Collection Endpoint

Expand All @@ -193,18 +193,18 @@ Collection Endpoint has the form:
*Syntax:*

```bnf
<collection-endpoint> ::= <server-address>/<namespace-name>/<collection-name>
<collection-endpoint> ::= <server-address>/<keyspace-name>/<collection-name>
```

`<collection-name>` must begin with an alpha-numeric character
and can only contain alpha-numeric characters and underscores.

*Sample:*

https://stargate.mycompany.com/my-namespace/users
https://stargate.mycompany.com/my-keyspace/users

Requests sent to a Collection that does not exist (using a valid
namespace name) result in the creation of the Collection and delivery of
keyspace name) result in the creation of the Collection and delivery of
the message. This may take longer than delivering a message to an
existing Collection.

Expand Down
32 changes: 16 additions & 16 deletions docs/dataapi-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ library such as [Mongoose](https://github.com/Automattic/mongoose).
- [High-level concepts](#high-level-concepts)
- [Conventions](#conventions)
- [Request and Response Messages](#request-and-response-messages)
- [Namespace](#namespace)
- [Keyspace](#keyspace)
- [Collections](#collections)
- [Documents](#documents)
- [Commands](#commands)
Expand All @@ -27,7 +27,7 @@ Additionally consideration should be given to implementing that API such that th

The DATA API consists of the following high level concepts that are composed to create a request:

- **Namespace:** A logical container representing a distinct storage location and query boundary which can contain multiple collections. May map to a keyspace or database.
- **Keyspace:** Keyspace of Cassandra
- **Collection:** A logical container of documents that have some meaning to the developer using the API. Often an ODM may map a single developer defined class or type to a collection.
- **Document:** A document is a hierarchical [JSON](https://www.json.org/) document with a single reserved `_id` field. All documents in a collection may have different fields and structure.
- **Command:** Commands are performed on Collections of Documents. Commands may return zero or more documents from the collection, update or insert zero or more documents, or both.
Expand Down Expand Up @@ -197,23 +197,23 @@ state.
```


## Namespace
## Keyspace

**TODO:** define the namespace, its properties, etc. Do we define how to create one?
**TODO:** define the keyspace, its properties, etc. Do we define how to create one?

### Namespace Limits
### Keyspace Limits

#### Namespace Name Limit
#### Keyspace Name Limit

Namespace names must follow the regular expression pattern below:
Keyspace names must follow the regular expression pattern below:

*Syntax:*

```bnf
<namespace-name> ::= ["a-zA-Z"]["a-zA-Z0-9_"]*
<keyspace-name> ::= ["a-zA-Z"]["a-zA-Z0-9_"]*
```

The maximum length of a namespace name is 48 characters.
The maximum length of a keyspace name is 48 characters.


## Collections
Expand Down Expand Up @@ -569,7 +569,7 @@ If an error occurs the command will not return `status`.

### createCollection Command

Creates a new collection in the current namespace.
Creates a new collection in the current keyspace.

*Sample*

Expand Down Expand Up @@ -838,9 +838,9 @@ If an error occurs the command will not return `data`.

### findCollections Command

`findCollections` returns all collections from a given namespace.
`findCollections` returns all collections from a given keyspace.

There is no payload. The `namespace` is given as `{{base_url}}{{json_port}}/v1/{namespace}`.
There is no payload. The `keyspace` is given as `{{base_url}}{{json_port}}/v1/{keyspace}`.

*Syntax:*

Expand All @@ -855,10 +855,10 @@ None.

#### findCollections Command Response

| Response Elements | Description |
| ----------------- | ---------------------------------------------------------------------------------- |
| `status` | Status has `collections` field with array of the available collection names. |
| `errors` | If the provided namespace does not exist, return `NAMESPACE_DOES_NOT_EXIST`. |
| Response Elements | Description |
| ----------------- |------------------------------------------------------------------------------|
| `status` | Status has `collections` field with array of the available collection names. |
| `errors` | If the provided keyspace does not exist, return `KEYSPACE_DOES_NOT_EXIST`. |


### findOneAndReplace Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* (see https://github.com/quarkusio/quarkus/issues/7690).
*/
public abstract class AbstractCollectionIntegrationTestBase
extends AbstractNamespaceIntegrationTestBase {
extends AbstractKeyspaceIntegrationTestBase {

// collection name automatically created in this test
protected final String collectionName = "col" + RandomStringUtils.randomAlphanumeric(16);
Expand All @@ -29,7 +29,7 @@ public final void createSimpleCollection() {
}

protected void createSimpleCollection(String collectionToCreate) {
createCollection(this.namespaceName, collectionToCreate);
createCollection(this.keyspaceName, collectionToCreate);
}

protected void createComplexCollection(String collectionSetting) {
Expand All @@ -45,7 +45,7 @@ protected void createComplexCollection(String collectionSetting) {
"""
.formatted(collectionSetting))
.when()
.post(KeyspaceResource.BASE_PATH, namespaceName)
.post(KeyspaceResource.BASE_PATH, keyspaceName)
.then()
.statusCode(200);
}
Expand All @@ -67,7 +67,7 @@ protected void deleteAllDocuments() {
.contentType(ContentType.JSON)
.body(json)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.statusCode(200)
.body("errors", is(nullValue()))
Expand Down Expand Up @@ -101,7 +101,7 @@ protected void insertDoc(String collection, String docJson) {
.contentType(ContentType.JSON)
.body(doc)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collection)
.post(CollectionResource.BASE_PATH, keyspaceName, collection)
.then()
// Sanity check: let's look for non-empty inserted id
.body("status.insertedIds[0]", not(emptyString()))
Expand All @@ -125,7 +125,7 @@ protected void insertManyDocs(String docsJson, int docsAmount) {
.contentType(ContentType.JSON)
.body(doc)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.body("status.insertedIds", hasSize(docsAmount))
.statusCode(200);
Expand All @@ -135,7 +135,7 @@ protected void insertManyDocs(String docsJson, int docsAmount) {
protected ValidatableResponse givenHeadersPostJsonThen(String json) {
return givenHeadersAndJson(json)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
* (see https://github.com/quarkusio/quarkus/issues/7690).
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractNamespaceIntegrationTestBase {
public abstract class AbstractKeyspaceIntegrationTestBase {

// keyspace automatically created in this test
protected final String namespaceName = "ns" + RandomStringUtils.randomAlphanumeric(16);
protected final String keyspaceName = "ks" + RandomStringUtils.randomAlphanumeric(16);

@BeforeAll
public static void enableLog() {
Expand All @@ -43,7 +43,7 @@ public static void enableLog() {

@BeforeAll
public void createKeyspace() {
createKeyspace(namespaceName);
createKeyspace(keyspaceName);
}

protected void createKeyspace(String nsToCreate) {
Expand Down Expand Up @@ -80,7 +80,7 @@ public void dropKeyspace() {
}
}
"""
.formatted(namespaceName);
.formatted(keyspaceName);

given()
.port(getTestPort())
Expand Down Expand Up @@ -110,7 +110,7 @@ protected void createCollection(String keyspace, String collectionToCreate) {
"""
.formatted(collectionToCreate))
.when()
.post(KeyspaceResource.BASE_PATH, namespaceName)
.post(KeyspaceResource.BASE_PATH, keyspaceName)
.then()
.statusCode(200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@QuarkusIntegrationTest
@WithTestResource(value = DseTestResource.class, restrictToAnnotatedClass = false)
class CollectionResourceIntegrationTest extends AbstractNamespaceIntegrationTestBase {
class CollectionResourceIntegrationTest extends AbstractKeyspaceIntegrationTestBase {
@Nested
class ClientErrors {
String collectionName = "col" + RandomStringUtils.randomAlphanumeric(16);
Expand All @@ -24,7 +24,7 @@ public void tokenMissing() {
.contentType(ContentType.JSON)
.body("{}")
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.statusCode(401)
.body(
Expand All @@ -40,7 +40,7 @@ public void malformedBody() {
.contentType(ContentType.JSON)
.body("wrong")
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
// 10-Jul-2024, tatu: As per [data-api#1216], should be 400, not 200
// (we want to return 4xx because we cannot actually process the request
Expand Down Expand Up @@ -70,7 +70,7 @@ public void unknownCommand() {
.contentType(ContentType.JSON)
.body(json)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.statusCode(200)
.body("errors", hasSize(1))
Expand Down Expand Up @@ -98,7 +98,7 @@ public void unknownCommandField() {
.contentType(ContentType.JSON)
.body(json)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.statusCode(200)
.body("errors", hasSize(1))
Expand Down Expand Up @@ -155,7 +155,7 @@ public void invalidCollectionName() {
.contentType(ContentType.JSON)
.body(json)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, "7_no_leading_number")
.post(CollectionResource.BASE_PATH, keyspaceName, "7_no_leading_number")
.then()
.statusCode(200)
.body("errors", hasSize(1))
Expand All @@ -173,7 +173,7 @@ public void emptyBody() {
.headers(getHeaders())
.contentType(ContentType.JSON)
.when()
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.post(CollectionResource.BASE_PATH, keyspaceName, collectionName)
.then()
.statusCode(200)
.body("errors", hasSize(1))
Expand Down
Loading

0 comments on commit 292ff5d

Please sign in to comment.