Skip to content

Commit

Permalink
go: Put parameters on separate lines for API methods
Browse files Browse the repository at this point in the history
… to reduce the diff of the upcoming codegen PR.
  • Loading branch information
svix-jplatte committed Jan 10, 2025
1 parent 59170d7 commit 4b5f74c
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 84 deletions.
49 changes: 40 additions & 9 deletions go/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ type ApplicationListOptions struct {
Order *Ordering
}

func (a *Application) List(ctx context.Context, options *ApplicationListOptions) (*ListResponseApplicationOut, error) {
func (a *Application) List(
ctx context.Context,
options *ApplicationListOptions,
) (*ListResponseApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationList(ctx)
if options != nil {
if options.Iterator != nil {
Expand All @@ -39,11 +42,18 @@ func (a *Application) List(ctx context.Context, options *ApplicationListOptions)
return ret, nil
}

func (a *Application) Create(ctx context.Context, applicationIn *ApplicationIn) (*ApplicationOut, error) {
func (a *Application) Create(
ctx context.Context,
applicationIn *ApplicationIn,
) (*ApplicationOut, error) {
return a.CreateWithOptions(ctx, applicationIn, nil)
}

func (a *Application) CreateWithOptions(ctx context.Context, applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error) {
func (a *Application) CreateWithOptions(
ctx context.Context,
applicationIn *ApplicationIn,
options *PostOptions,
) (*ApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationCreate(ctx)
req = req.ApplicationIn(*applicationIn)
if options != nil {
Expand All @@ -58,11 +68,18 @@ func (a *Application) CreateWithOptions(ctx context.Context, applicationIn *Appl
return ret, nil
}

func (a *Application) GetOrCreate(ctx context.Context, applicationIn *ApplicationIn) (*ApplicationOut, error) {
func (a *Application) GetOrCreate(
ctx context.Context,
applicationIn *ApplicationIn,
) (*ApplicationOut, error) {
return a.GetOrCreateWithOptions(ctx, applicationIn, nil)
}

func (a *Application) GetOrCreateWithOptions(ctx context.Context, applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error) {
func (a *Application) GetOrCreateWithOptions(
ctx context.Context,
applicationIn *ApplicationIn,
options *PostOptions,
) (*ApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationCreate(ctx)
req = req.ApplicationIn(*applicationIn)
req = req.GetIfExists(true)
Expand All @@ -78,7 +95,10 @@ func (a *Application) GetOrCreateWithOptions(ctx context.Context, applicationIn
return ret, nil
}

func (a *Application) Get(ctx context.Context, appId string) (*ApplicationOut, error) {
func (a *Application) Get(
ctx context.Context,
appId string,
) (*ApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationGet(ctx, appId)
ret, res, err := req.Execute()
if err != nil {
Expand All @@ -87,7 +107,11 @@ func (a *Application) Get(ctx context.Context, appId string) (*ApplicationOut, e
return ret, nil
}

func (a *Application) Update(ctx context.Context, appId string, applicationIn *ApplicationIn) (*ApplicationOut, error) {
func (a *Application) Update(
ctx context.Context,
appId string,
applicationIn *ApplicationIn,
) (*ApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationUpdate(ctx, appId)
req = req.ApplicationIn(*applicationIn)
ret, res, err := req.Execute()
Expand All @@ -97,7 +121,11 @@ func (a *Application) Update(ctx context.Context, appId string, applicationIn *A
return ret, nil
}

func (a *Application) Patch(ctx context.Context, appId string, applicationPatch *ApplicationPatch) (*ApplicationOut, error) {
func (a *Application) Patch(
ctx context.Context,
appId string,
applicationPatch *ApplicationPatch,
) (*ApplicationOut, error) {
req := a.api.ApplicationAPI.V1ApplicationPatch(ctx, appId)
req = req.ApplicationPatch(*applicationPatch)
ret, res, err := req.Execute()
Expand All @@ -107,7 +135,10 @@ func (a *Application) Patch(ctx context.Context, appId string, applicationPatch
return ret, nil
}

func (a *Application) Delete(ctx context.Context, appId string) error {
func (a *Application) Delete(
ctx context.Context,
appId string,
) error {
req := a.api.ApplicationAPI.V1ApplicationDelete(ctx, appId)
res, err := req.Execute()
return wrapError(err, res)
Expand Down
33 changes: 27 additions & 6 deletions go/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ type Authentication struct {
api *openapi.APIClient
}

func (a *Authentication) AppPortalAccess(ctx context.Context, appId string, appPortalAccessIn *AppPortalAccessIn) (*AppPortalAccessOut, error) {
func (a *Authentication) AppPortalAccess(
ctx context.Context,
appId string,
appPortalAccessIn *AppPortalAccessIn,
) (*AppPortalAccessOut, error) {
return a.AppPortalAccessWithOptions(ctx, appId, appPortalAccessIn, nil)
}

func (a *Authentication) AppPortalAccessWithOptions(ctx context.Context, appId string, appPortalAccessIn *AppPortalAccessIn, options *PostOptions) (*AppPortalAccessOut, error) {
func (a *Authentication) AppPortalAccessWithOptions(
ctx context.Context,
appId string,
appPortalAccessIn *AppPortalAccessIn,
options *PostOptions,
) (*AppPortalAccessOut, error) {
req := a.api.AuthenticationAPI.V1AuthenticationAppPortalAccess(ctx, appId)
req = req.AppPortalAccessIn(*appPortalAccessIn)
if options != nil {
Expand All @@ -29,11 +38,18 @@ func (a *Authentication) AppPortalAccessWithOptions(ctx context.Context, appId s
return ret, nil
}

func (a *Authentication) DashboardAccess(ctx context.Context, appId string) (*DashboardAccessOut, error) {
func (a *Authentication) DashboardAccess(
ctx context.Context,
appId string,
) (*DashboardAccessOut, error) {
return a.DashboardAccessWithOptions(ctx, appId, nil)
}

func (a *Authentication) DashboardAccessWithOptions(ctx context.Context, appId string, options *PostOptions) (*DashboardAccessOut, error) {
func (a *Authentication) DashboardAccessWithOptions(
ctx context.Context,
appId string,
options *PostOptions,
) (*DashboardAccessOut, error) {
req := a.api.AuthenticationAPI.V1AuthenticationDashboardAccess(ctx, appId)
if options != nil {
if options.IdempotencyKey != nil {
Expand All @@ -47,11 +63,16 @@ func (a *Authentication) DashboardAccessWithOptions(ctx context.Context, appId s
return ret, nil
}

func (a *Authentication) Logout(ctx context.Context) error {
func (a *Authentication) Logout(
ctx context.Context,
) error {
return a.LogoutWithOptions(ctx, nil)
}

func (a *Authentication) LogoutWithOptions(ctx context.Context, options *PostOptions) error {
func (a *Authentication) LogoutWithOptions(
ctx context.Context,
options *PostOptions,
) error {
req := a.api.AuthenticationAPI.V1AuthenticationLogout(ctx)
if options != nil {
if options.IdempotencyKey != nil {
Expand Down
10 changes: 8 additions & 2 deletions go/backgroundtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ type BackgroundTaskListOptions struct {
Task *BackgroundTaskType
}

func (a *BackgroundTask) List(ctx context.Context, options *BackgroundTaskListOptions) (*ListResponseBackgroundTaskOut, error) {
func (a *BackgroundTask) List(
ctx context.Context,
options *BackgroundTaskListOptions,
) (*ListResponseBackgroundTaskOut, error) {
req := a.api.BackgroundTasksAPI.ListBackgroundTasks(ctx)
if options != nil {
if options.Iterator != nil {
Expand All @@ -44,7 +47,10 @@ func (a *BackgroundTask) List(ctx context.Context, options *BackgroundTaskListOp
return ret, nil
}

func (a *BackgroundTask) Get(ctx context.Context, taskId string) (*BackgroundTaskOut, error) {
func (a *BackgroundTask) Get(
ctx context.Context,
taskId string,
) (*BackgroundTaskOut, error) {
req := a.api.BackgroundTasksAPI.GetBackgroundTask(ctx, taskId)
ret, res, err := req.Execute()
if err != nil {
Expand Down
Loading

0 comments on commit 4b5f74c

Please sign in to comment.