Skip to content

Commit

Permalink
feat(aep/217): add support for unreachable resources
Browse files Browse the repository at this point in the history
aep-217 support for unreachable resources.
  • Loading branch information
toumorokoshi committed Nov 5, 2024
1 parent d92cff4 commit 0b54efa
Show file tree
Hide file tree
Showing 11 changed files with 544 additions and 463 deletions.
22 changes: 12 additions & 10 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
// limitations under the License.
package constants

const FIELD_PAGE_TOKEN_NAME = "page_token"
const FIELD_PAGE_TOKEN_NUMBER = 10010
const FIELD_NEXT_PAGE_TOKEN_NAME = "next_page_token"
const FIELD_NEXT_PAGE_TOKEN_NUMBER = 10011
const FIELD_UPDATE_MASK_NAME = "update_mask"
const FIELD_UPDATE_MASK_NUMBER = 10012
const FIELD_PARENT_NAME = "parent"
const FIELD_PARENT_NUMBER = 10013
const FIELD_PATH_NAME = "path"
const FIELD_PATH_NUMBER = 10018
const FIELD_ID_NAME = "id"
const FIELD_ID_NUMBER = 10014
const FIELD_RESOURCE_NAME = "resource"
const FIELD_RESOURCE_NUMBER = 10015
const FIELD_RESOURCES_NAME = "resources"
const FIELD_RESOURCES_NUMBER = 10016
const FIELD_PAGE_TOKEN_NAME = "page_token"
const FIELD_PAGE_TOKEN_NUMBER = 10010
const FIELD_UPDATE_MASK_NAME = "update_mask"
const FIELD_UPDATE_MASK_NUMBER = 10012
const FIELD_MAX_PAGE_SIZE_NAME = "max_page_size"
const FIELD_MAX_PAGE_SIZE_NUMBER = 10017
const FIELD_NEXT_PAGE_TOKEN_NAME = "next_page_token"
const FIELD_NEXT_PAGE_TOKEN_NUMBER = 10011
const FIELD_ID_NAME = "id"
const FIELD_ID_NUMBER = 10014
const FIELD_PATH_NAME = "path"
const FIELD_PATH_NUMBER = 10018
const FIELD_UNREACHABLE_RESOURCES_NAME = "unreachable"
const FIELD_UNREACHABLE_RESOURCES_NUMBER = 10019
740 changes: 381 additions & 359 deletions example/bookstore/v1/bookstore.pb.go

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions example/bookstore/v1/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ message Book {
string lastName = 2;
}

// Field for author.
repeated Author author = 5;

// Field for isbn.
repeated string isbn = 1 [(google.api.field_behavior) = REQUIRED];

// Field for price.
float price = 2 [(google.api.field_behavior) = REQUIRED];

Expand All @@ -187,6 +181,12 @@ message Book {
// Field for edition.
int32 edition = 4;

// Field for author.
repeated Author author = 5;

// Field for etag.
string etag = 6;

// Field for path.
string path = 10000;

Expand Down Expand Up @@ -264,6 +264,9 @@ message ListBooksResponse {

// The page token indicating the ending point of this response.
string next_page_token = 10011;

// The resources that are unreachable.
string unreachable = 10019;
}

// Request message for the Applybook method
Expand Down Expand Up @@ -385,6 +388,9 @@ message Publisher {
// Field for description.
string description = 1;

// Field for etag.
string etag = 2;

// Field for path.
string path = 10000;

Expand Down
36 changes: 20 additions & 16 deletions example/bookstore/v1/bookstore.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,21 +809,6 @@
"v1Book": {
"type": "object",
"properties": {
"author": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/BookAuthor"
},
"description": "Field for author."
},
"isbn": {
"type": "array",
"items": {
"type": "string"
},
"description": "Field for isbn."
},
"price": {
"type": "number",
"format": "float",
Expand All @@ -838,6 +823,18 @@
"format": "int32",
"description": "Field for edition."
},
"author": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/BookAuthor"
},
"description": "Field for author."
},
"etag": {
"type": "string",
"description": "Field for etag."
},
"path": {
"type": "string",
"description": "Field for path."
Expand All @@ -849,7 +846,6 @@
},
"description": "A Book.",
"required": [
"isbn",
"price",
"published"
]
Expand Down Expand Up @@ -921,6 +917,10 @@
"nextPageToken": {
"type": "string",
"description": "The page token indicating the ending point of this response."
},
"unreachable": {
"type": "string",
"description": "The resources that are unreachable."
}
},
"title": "Response message for the Listbook method"
Expand Down Expand Up @@ -950,6 +950,10 @@
"type": "string",
"description": "Field for description."
},
"etag": {
"type": "string",
"description": "Field for etag."
},
"path": {
"type": "string",
"description": "Field for path."
Expand Down
15 changes: 9 additions & 6 deletions example/bookstore/v1/bookstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ resources:
description:
type: STRING
number: 1
etag:
type: STRING
number: 2
methods:
create: {}
read: {}
Expand All @@ -24,11 +27,9 @@ resources:
parents:
- "publisher"
properties:
isbn:
array_type:
type: STRING
number: 1
required: true
etag:
type: STRING
number: 6
price:
type: FLOAT
number: 2
Expand All @@ -42,6 +43,7 @@ resources:
number: 4
required: false
author:
number: 5
array_type:
object_type:
properties:
Expand All @@ -56,7 +58,8 @@ resources:
read: {}
update: {}
delete: {}
list: {}
list:
unreachable_resources: true
apply: {} # do not uncomment until there is an AEP on apply.
# other example resources that might be interesting to add:
# authors, which could be a reference for book
Expand Down
19 changes: 12 additions & 7 deletions example/bookstore/v1/bookstore_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@
"items": {
"$ref": "#/components/schemas/book"
}
},
"unreachable": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Expand Down Expand Up @@ -651,7 +657,6 @@
"book": {
"type": "object",
"required": [
"isbn",
"price",
"published"
],
Expand All @@ -666,17 +671,14 @@
"type": "integer",
"format": "int32"
},
"etag": {
"type": "string"
},
"id": {
"type": "string",
"readOnly": true,
"x-terraform-id": true
},
"isbn": {
"type": "array",
"items": {
"type": "string"
}
},
"path": {
"type": "string",
"readOnly": true
Expand Down Expand Up @@ -757,6 +759,9 @@
"description": {
"type": "string"
},
"etag": {
"type": "string"
},
"id": {
"type": "string",
"readOnly": true,
Expand Down
13 changes: 8 additions & 5 deletions example/bookstore/v1/bookstore_openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ components:
edition:
format: int32
type: integer
etag:
type: string
id:
readOnly: true
type: string
x-terraform-id: true
isbn:
items:
type: string
type: array
path:
readOnly: true
type: string
Expand All @@ -26,7 +24,6 @@ components:
published:
type: boolean
required:
- isbn
- price
- published
type: object
Expand Down Expand Up @@ -77,6 +74,8 @@ components:
properties:
description:
type: string
etag:
type: string
id:
readOnly: true
type: string
Expand Down Expand Up @@ -270,6 +269,10 @@ paths:
items:
$ref: '#/components/schemas/book'
type: array
unreachable:
items:
type: string
type: array
type: object
description: Successful response
post:
Expand Down
Loading

0 comments on commit 0b54efa

Please sign in to comment.