Skip to content

Commit 0dd42ec

Browse files
feat(authz): update openapi spec (#10382)
1 parent 34ba5ba commit 0dd42ec

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

docs/api/openapi.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ components:
100100
$ref: '#/components/schemas/AuthtypesObject'
101101
relation:
102102
type: string
103+
required:
104+
- relation
105+
- object
106+
- authorized
103107
type: object
104108
AuthtypesGoogleConfig:
105109
properties:
@@ -1672,6 +1676,9 @@ components:
16721676
$ref: '#/components/schemas/AuthtypesResource'
16731677
nullable: true
16741678
type: array
1679+
required:
1680+
- resources
1681+
- relations
16751682
type: object
16761683
RoletypesPatchableObjects:
16771684
properties:
@@ -1692,8 +1699,9 @@ components:
16921699
RoletypesPatchableRole:
16931700
properties:
16941701
description:
1695-
nullable: true
16961702
type: string
1703+
required:
1704+
- description
16971705
type: object
16981706
RoletypesPostableRole:
16991707
properties:
@@ -1722,6 +1730,11 @@ components:
17221730
updatedAt:
17231731
format: date-time
17241732
type: string
1733+
required:
1734+
- name
1735+
- description
1736+
- type
1737+
- orgId
17251738
type: object
17261739
TelemetrytypesFieldContext:
17271740
enum:

frontend/src/api/generated/services/sigNoz.schemas.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ export interface AuthtypesGettableTransactionDTO {
131131
/**
132132
* @type boolean
133133
*/
134-
authorized?: boolean;
135-
object?: AuthtypesObjectDTO;
134+
authorized: boolean;
135+
object: AuthtypesObjectDTO;
136136
/**
137137
* @type string
138138
*/
139-
relation?: string;
139+
relation: string;
140140
}
141141

142142
export type AuthtypesGoogleConfigDTODomainToAdminEmail = {
@@ -2004,12 +2004,12 @@ export interface RoletypesGettableResourcesDTO {
20042004
* @type object
20052005
* @nullable true
20062006
*/
2007-
relations?: RoletypesGettableResourcesDTORelations;
2007+
relations: RoletypesGettableResourcesDTORelations;
20082008
/**
20092009
* @type array
20102010
* @nullable true
20112011
*/
2012-
resources?: AuthtypesResourceDTO[] | null;
2012+
resources: AuthtypesResourceDTO[] | null;
20132013
}
20142014

20152015
export interface RoletypesPatchableObjectsDTO {
@@ -2028,9 +2028,8 @@ export interface RoletypesPatchableObjectsDTO {
20282028
export interface RoletypesPatchableRoleDTO {
20292029
/**
20302030
* @type string
2031-
* @nullable true
20322031
*/
2033-
description?: string | null;
2032+
description: string;
20342033
}
20352034

20362035
export interface RoletypesPostableRoleDTO {
@@ -2053,23 +2052,23 @@ export interface RoletypesRoleDTO {
20532052
/**
20542053
* @type string
20552054
*/
2056-
description?: string;
2055+
description: string;
20572056
/**
20582057
* @type string
20592058
*/
20602059
id?: string;
20612060
/**
20622061
* @type string
20632062
*/
2064-
name?: string;
2063+
name: string;
20652064
/**
20662065
* @type string
20672066
*/
2068-
orgId?: string;
2067+
orgId: string;
20692068
/**
20702069
* @type string
20712070
*/
2072-
type?: string;
2071+
type: string;
20732072
/**
20742073
* @type string
20752074
* @format date-time

pkg/types/authtypes/transaction.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ type Transaction struct {
2626
}
2727

2828
type GettableTransaction struct {
29-
Relation Relation `json:"relation"`
30-
Object Object `json:"object"`
31-
Authorized bool `json:"authorized"`
29+
Relation Relation `json:"relation" required:"true"`
30+
Object Object `json:"object" required:"true"`
31+
Authorized bool `json:"authorized" required:"true"`
3232
}
3333

3434
func NewObject(resource Resource, selector Selector) (*Object, error) {

pkg/types/roletypes/role.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ type StorableRole struct {
6969
type Role struct {
7070
types.Identifiable
7171
types.TimeAuditable
72-
Name string `json:"name"`
73-
Description string `json:"description"`
74-
Type valuer.String `json:"type"`
75-
OrgID valuer.UUID `json:"orgId"`
72+
Name string `json:"name" required:"true"`
73+
Description string `json:"description" required:"true"`
74+
Type valuer.String `json:"type" required:"true"`
75+
OrgID valuer.UUID `json:"orgId" required:"true"`
7676
}
7777

7878
type PostableRole struct {
@@ -81,7 +81,7 @@ type PostableRole struct {
8181
}
8282

8383
type PatchableRole struct {
84-
Description *string `json:"description"`
84+
Description string `json:"description" required:"true"`
8585
}
8686

8787
type PatchableObjects struct {
@@ -90,8 +90,8 @@ type PatchableObjects struct {
9090
}
9191

9292
type GettableResources struct {
93-
Resources []*authtypes.Resource `json:"resources"`
94-
Relations map[authtypes.Type][]authtypes.Relation `json:"relations"`
93+
Resources []*authtypes.Resource `json:"resources" required:"true"`
94+
Relations map[authtypes.Type][]authtypes.Relation `json:"relations" required:"true"`
9595
}
9696

9797
func NewStorableRoleFromRole(role *Role) *StorableRole {
@@ -149,15 +149,13 @@ func NewGettableResources(resources []*authtypes.Resource) *GettableResources {
149149
}
150150
}
151151

152-
func (role *Role) PatchMetadata(description *string) error {
152+
func (role *Role) PatchMetadata(description string) error {
153153
err := role.CanEditDelete()
154154
if err != nil {
155155
return err
156156
}
157157

158-
if description != nil {
159-
role.Description = *description
160-
}
158+
role.Description = description
161159
role.UpdatedAt = time.Now()
162160
return nil
163161
}
@@ -222,15 +220,15 @@ func (role *PostableRole) UnmarshalJSON(data []byte) error {
222220

223221
func (role *PatchableRole) UnmarshalJSON(data []byte) error {
224222
type shadowPatchableRole struct {
225-
Description *string `json:"description"`
223+
Description string `json:"description"`
226224
}
227225

228226
var shadowRole shadowPatchableRole
229227
if err := json.Unmarshal(data, &shadowRole); err != nil {
230228
return err
231229
}
232230

233-
if shadowRole.Description == nil {
231+
if shadowRole.Description == "" {
234232
return errors.New(errors.TypeInvalidInput, ErrCodeRoleEmptyPatch, "empty role patch request received, description must be present")
235233
}
236234

0 commit comments

Comments
 (0)