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

fix: read relation tuples must require namspace query parameter only #760

Merged
merged 2 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/e2e/sdk_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func (c *sdkClient) deleteTuple(t require.TestingT, r *relationtuple.InternalRel
func compileParams(q *relationtuple.RelationQuery, opts []x.PaginationOptionSetter) *read.GetRelationTuplesParams {
params := read.NewGetRelationTuplesParams().WithNamespace(q.Namespace)
if q.Relation != "" {
params = params.WithRelation(q.Relation)
params = params.WithRelation(&q.Relation)
}
if q.Object != "" {
params = params.WithObject(q.Object)
params = params.WithObject(&q.Object)
}
if q.SubjectID != nil {
params = params.WithSubjectID(q.SubjectID)
Expand Down
50 changes: 32 additions & 18 deletions internal/httpclient/client/read/get_relation_tuples_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions internal/relationtuple/read_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,46 @@ func (h *handler) ListRelationTuples(ctx context.Context, req *acl.ListRelationT
// swagger:parameters getRelationTuples
// nolint:deadcode,unused
type getRelationsParams struct {
// swagger:allOf
queryRelationTuple
// Namespace of the Relation Tuple
//
// in: query
// required: true
Namespace string `json:"namespace"`

// Object of the Relation Tuple
//
// in: query
Object string `json:"object"`

// Relation of the Relation Tuple
//
// in: query
Relation string `json:"relation"`

// SubjectID of the Relation Tuple
//
// in: query
// Either subject_set.* or subject_id are required.
SubjectID string `json:"subject_id"`

// Namespace of the Subject Set
//
// in: query
// Either subject_set.* or subject_id are required.
SNamespace string `json:"subject_set.namespace"`

// Object of the Subject Set
//
// in: query
// Either subject_set.* or subject_id are required.
SObject string `json:"subject_set.object"`

// Relation of the Subject Set
//
// in: query
// Either subject_set.* or subject_id are required.
SRelation string `json:"subject_set.relation"`

// swagger:allOf
x.PaginationOptions
}
Expand Down
28 changes: 13 additions & 15 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,17 @@
"summary": "Query relation tuples",
"operationId": "getRelationTuples",
"parameters": [
{
"type": "string",
"name": "page_token",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "Namespace of the Relation Tuple",
Expand All @@ -532,15 +543,13 @@
"type": "string",
"description": "Object of the Relation Tuple",
"name": "object",
"in": "query",
"required": true
"in": "query"
},
{
"type": "string",
"description": "Relation of the Relation Tuple",
"name": "relation",
"in": "query",
"required": true
"in": "query"
},
{
"type": "string",
Expand All @@ -565,17 +574,6 @@
"description": "Relation of the Subject Set",
"name": "subject_set.relation",
"in": "query"
},
{
"type": "string",
"name": "page_token",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "page_size",
"in": "query"
}
],
"responses": {
Expand Down