feat: add template for webhook db methods

This commit is contained in:
Lakhan Samani 2022-07-06 10:38:21 +05:30
parent 265331801f
commit a8064e79a1
15 changed files with 1625 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package arangodb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhook to add webhook
func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// UpdateWebhook to update webhook
func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// ListWebhooks to list webhook
func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) {
return nil, nil
}
// GetWebhookByID to get webhook by id
func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// GetWebhookByEvent to get webhook by event_name
func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// DeleteWebhook to delete webhook
func (p *provider) DeleteWebhook(webhookID string) error {
return nil
}

View File

@ -0,0 +1,16 @@
package arangodb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhookLog to add webhook log
func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) {
return webhookLog, nil
}
// ListWebhookLogs to list webhook logs
func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
return nil, nil
}

View File

@ -0,0 +1,36 @@
package cassandradb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhook to add webhook
func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// UpdateWebhook to update webhook
func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// ListWebhooks to list webhook
func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) {
return nil, nil
}
// GetWebhookByID to get webhook by id
func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// GetWebhookByEvent to get webhook by event_name
func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// DeleteWebhook to delete webhook
func (p *provider) DeleteWebhook(webhookID string) error {
return nil
}

View File

@ -0,0 +1,16 @@
package cassandradb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhookLog to add webhook log
func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) {
return webhookLog, nil
}
// ListWebhookLogs to list webhook logs
func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
return nil, nil
}

View File

@ -0,0 +1,36 @@
package mongodb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhook to add webhook
func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// UpdateWebhook to update webhook
func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// ListWebhooks to list webhook
func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) {
return nil, nil
}
// GetWebhookByID to get webhook by id
func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// GetWebhookByEvent to get webhook by event_name
func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// DeleteWebhook to delete webhook
func (p *provider) DeleteWebhook(webhookID string) error {
return nil
}

View File

@ -0,0 +1,16 @@
package mongodb
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhookLog to add webhook log
func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) {
return webhookLog, nil
}
// ListWebhookLogs to list webhook logs
func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
return nil, nil
}

View File

@ -0,0 +1,36 @@
package provider_template
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhook to add webhook
func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// UpdateWebhook to update webhook
func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// ListWebhooks to list webhook
func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) {
return nil, nil
}
// GetWebhookByID to get webhook by id
func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// GetWebhookByEvent to get webhook by event_name
func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// DeleteWebhook to delete webhook
func (p *provider) DeleteWebhook(webhookID string) error {
return nil
}

View File

@ -0,0 +1,16 @@
package provider_template
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhookLog to add webhook log
func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) {
return webhookLog, nil
}
// ListWebhookLogs to list webhook logs
func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
return nil, nil
}

View File

@ -41,4 +41,22 @@ type Provider interface {
UpdateEnv(env models.Env) (models.Env, error)
// GetEnv to get environment information from database
GetEnv() (models.Env, error)
// AddWebhook to add webhook
AddWebhook(webhook models.Webhook) (models.Webhook, error)
// UpdateWebhook to update webhook
UpdateWebhook(webhook models.Webhook) (models.Webhook, error)
// ListWebhooks to list webhook
ListWebhook(pagination model.Pagination) (*model.Webhooks, error)
// GetWebhookByID to get webhook by id
GetWebhookByID(webhookID string) (models.Webhook, error)
// GetWebhookByEvent to get webhook by event_name
GetWebhookByEvent(eventName string) (models.Webhook, error)
// DeleteWebhook to delete webhook
DeleteWebhook(webhookID string) error
// AddWebhookLog to add webhook log
AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error)
// ListWebhookLogs to list webhook logs
ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error)
}

View File

@ -0,0 +1,36 @@
package sql
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhook to add webhook
func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// UpdateWebhook to update webhook
func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) {
return webhook, nil
}
// ListWebhooks to list webhook
func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) {
return nil, nil
}
// GetWebhookByID to get webhook by id
func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// GetWebhookByEvent to get webhook by event_name
func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) {
return models.Webhook{}, nil
}
// DeleteWebhook to delete webhook
func (p *provider) DeleteWebhook(webhookID string) error {
return nil
}

View File

@ -0,0 +1,16 @@
package sql
import (
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// AddWebhookLog to add webhook log
func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) {
return webhookLog, nil
}
// ListWebhookLogs to list webhook logs
func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
return nil, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -100,6 +100,11 @@ type InviteMemberInput struct {
RedirectURI *string `json:"redirect_uri"`
}
type ListWebhookLogRequest struct {
Pagination *PaginatedInput `json:"pagination"`
WebhookID *string `json:"webhook_id"`
}
type LoginInput struct {
Email string `json:"email"`
Password string `json:"password"`
@ -319,3 +324,32 @@ type VerificationRequests struct {
type VerifyEmailInput struct {
Token string `json:"token"`
}
type Webhook struct {
ID string `json:"id"`
EventName *string `json:"event_name"`
Endpoint *string `json:"endpoint"`
Enabled *bool `json:"enabled"`
CreatedAt *int64 `json:"created_at"`
UpdatedAt *int64 `json:"updated_at"`
}
type WebhookLog struct {
ID string `json:"id"`
HTTPStatus *string `json:"http_status"`
Response *string `json:"response"`
Request *string `json:"request"`
WebhookID *string `json:"webhook_id"`
CreatedAt *int64 `json:"created_at"`
UpdatedAt *int64 `json:"updated_at"`
}
type WebhookLogs struct {
Pagination *Pagination `json:"pagination"`
WebhookLogs []*WebhookLog `json:"webhook_logs"`
}
type Webhooks struct {
Pagination *Pagination `json:"pagination"`
Webhooks []*Webhook `json:"webhooks"`
}

View File

@ -2,6 +2,7 @@
#
# https://gqlgen.com/getting-started/
scalar Int64
scalar Int32
scalar Map
scalar Any
@ -324,6 +325,40 @@ input GenerateJWTKeysInput {
type: String!
}
type Webhook {
id: ID!
event_name: String
endpoint: String
enabled: Boolean
created_at: Int64
updated_at: Int64
}
type Webhooks {
pagination: Pagination!
webhooks: [Webhook!]!
}
type WebhookLog {
id: ID!
http_status: Int32
response: String
request: String
webhook_id: ID
created_at: Int64
updated_at: Int64
}
input ListWebhookLogRequest {
pagination: PaginatedInput!
webhook_id: String
}
type WebhookLogs {
pagination: Pagination!
webhook_logs: [WebhookLog!]!
}
type Mutation {
signup(params: SignUpInput!): AuthResponse!
login(params: LoginInput!): AuthResponse!
@ -358,4 +393,6 @@ type Query {
_verification_requests(params: PaginatedInput): VerificationRequests!
_admin_session: Response!
_env: Env!
_webhooks(params: PaginatedInput): Webhooks!
_webhook_logs(params: ListWebhookLogRequest): WebhookLogs!
}

View File

@ -5,6 +5,7 @@ package graph
import (
"context"
"fmt"
"github.com/authorizerdev/authorizer/server/graph/generated"
"github.com/authorizerdev/authorizer/server/graph/model"
@ -123,6 +124,14 @@ func (r *queryResolver) Env(ctx context.Context) (*model.Env, error) {
return resolvers.EnvResolver(ctx)
}
func (r *queryResolver) Webhooks(ctx context.Context, params *model.PaginatedInput) (*model.Webhooks, error) {
panic(fmt.Errorf("not implemented"))
}
func (r *queryResolver) WebhookLogs(ctx context.Context, params *model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
panic(fmt.Errorf("not implemented"))
}
// Mutation returns generated.MutationResolver implementation.
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }