Skip to content

Commit

Permalink
External Ticketing (#136)
Browse files Browse the repository at this point in the history
* External Ticketing (#125)

* Initial protos for ticket service

* Add basics of ticketing

* Add support for creating a ticket using a json template

* Make custom fields a map

* Helper cleanup

* No need for type assertion from interface{} -> interface{}

* Support multiple ticket schemas as defined by the connector (#127)

* Make ticket schema endpoint paginated

* Update cli tooling to support fetching a schema of a specific ID before creating a ticket

* Add list ticket schemas to connectorbuilder

* Support for providing a schema ID when making a create ticket request

* Add ticket request message (#129)

* add ticket request message

* move annotations back to create ticket request

* Create ticket task (#131)

* wip create ticket task

* remove some comments

* Combine create ticket methods (#130)

* Include the schema ID in the ticket template

* Combine create ticket methods to use task

* Remove unused flag

* cleanup/add ticket request to task proto/handle task

* remove comment

* fix lint

* fix comment

---------

Co-authored-by: Justin Gallardo <justin.gallardo@conductorone.com>

* Add ticketing flag, and allow ticketing and provisioning to be enabled at the same time (#133)

* Add ListSchemas and GetTicketing tasks (#135)

* add list schemas and get ticket

* lint

* more lint

* Remove unused ticketing command

* Add noop ticketing implementation for if ticketing isn't explciitly enabled

* Rename ListSchemas to ListTicketSchemas

* Drop ticket comments from models for now

* Begin on unit testing custom fields

* test validate ticket

* Add tests for custom field helpers. Fix type checking bug

* Add more custom field helpers with tests (#137)

* CreateTicketRequest uses ticket schema instead of a ticket schema ID (#138)

* Add more custom field helpers with tests

* Update create ticket endpoint to take a ticket schema instead of an ID

* Be sure to update the create ticket task to have a ticket schema on it.

* Add new ticketing connector capability

* Custom field test cleanup  (#139)

* use/add helpers and options

* less lines

* fix lint

---------

Co-authored-by: Scott <scottmitchell2014@gmail.com>
Co-authored-by: laurenleach <106626058+laurenleach@users.noreply.github.com>
Co-authored-by: Lauren Leach <lauren.leach@conductorone.com>
  • Loading branch information
4 people authored May 17, 2024
1 parent 128b7cc commit 6a7f302
Show file tree
Hide file tree
Showing 24 changed files with 11,488 additions and 535 deletions.
18 changes: 18 additions & 0 deletions internal/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type connectorClient struct {
connectorV2.AccountManagerServiceClient
connectorV2.CredentialManagerServiceClient
connectorV2.EventServiceClient
connectorV2.TicketsServiceClient
}

var ErrConnectorNotImplemented = errors.New("client does not implement connector connectorV2")
Expand All @@ -55,6 +56,7 @@ type wrapper struct {
serverStdin io.WriteCloser
conn *grpc.ClientConn
provisioningEnabled bool
ticketingEnabled bool

rateLimiter ratelimitV1.RateLimiterServiceServer
rlCfg *ratelimitV1.RateLimiterConfig
Expand Down Expand Up @@ -93,6 +95,14 @@ func WithProvisioningEnabled() Option {
}
}

func WithTicketingEnabled() Option {
return func(ctx context.Context, w *wrapper) error {
w.ticketingEnabled = true

return nil
}
}

// NewConnectorWrapper returns a connector wrapper for running connector services locally.
func NewWrapper(ctx context.Context, server interface{}, opts ...Option) (*wrapper, error) {
connectorServer, isServer := server.(types.ConnectorServer)
Expand Down Expand Up @@ -143,6 +153,13 @@ func (cw *wrapper) Run(ctx context.Context, serverCfg *connectorwrapperV1.Server
connectorV2.RegisterAssetServiceServer(server, cw.server)
connectorV2.RegisterEventServiceServer(server, cw.server)

if cw.ticketingEnabled {
connectorV2.RegisterTicketsServiceServer(server, cw.server)
} else {
noop := &noopTicketing{}
connectorV2.RegisterTicketsServiceServer(server, noop)
}

if cw.provisioningEnabled {
connectorV2.RegisterGrantManagerServiceServer(server, cw.server)
connectorV2.RegisterResourceManagerServiceServer(server, cw.server)
Expand Down Expand Up @@ -314,6 +331,7 @@ func (cw *wrapper) C(ctx context.Context) (types.ConnectorClient, error) {
AccountManagerServiceClient: connectorV2.NewAccountManagerServiceClient(cw.conn),
CredentialManagerServiceClient: connectorV2.NewCredentialManagerServiceClient(cw.conn),
EventServiceClient: connectorV2.NewEventServiceClient(cw.conn),
TicketsServiceClient: connectorV2.NewTicketsServiceClient(cw.conn),
}

return cw.client, nil
Expand Down
26 changes: 26 additions & 0 deletions internal/connector/noop_ticketing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package connector

import (
"context"
"errors"

v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
)

type noopTicketing struct{}

func (n noopTicketing) CreateTicket(ctx context.Context, request *v2.TicketsServiceCreateTicketRequest) (*v2.TicketsServiceCreateTicketResponse, error) {
return nil, errors.New("ticketing is not enabled")
}

func (n noopTicketing) GetTicket(ctx context.Context, request *v2.TicketsServiceGetTicketRequest) (*v2.TicketsServiceGetTicketResponse, error) {
return nil, errors.New("ticketing is not enabled")
}

func (n noopTicketing) ListTicketSchemas(ctx context.Context, request *v2.TicketsServiceListTicketSchemasRequest) (*v2.TicketsServiceListTicketSchemasResponse, error) {
return nil, errors.New("ticketing is not enabled")
}

func (n noopTicketing) GetTicketSchema(ctx context.Context, request *v2.TicketsServiceGetTicketSchemaRequest) (*v2.TicketsServiceGetTicketSchemaResponse, error) {
return nil, errors.New("ticketing is not enabled")
}
57 changes: 31 additions & 26 deletions pb/c1/connector/v2/connector.pb.go

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

Loading

0 comments on commit 6a7f302

Please sign in to comment.