Skip to content

Commit

Permalink
chore: default list methods to descending order (#306)
Browse files Browse the repository at this point in the history
* chore: default list methods to descending order

* fix: indentation

* chore: bump to v4

* bump version

* update CI image
  • Loading branch information
faroceann authored Mar 8, 2024
1 parent 6b3f9d0 commit 7c8f3e3
Show file tree
Hide file tree
Showing 34 changed files with 95 additions and 66 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WorkOS Go Library

[![Go Reference](https://pkg.go.dev/badge/github.com/workos/workos-go/v3.svg)](https://pkg.go.dev/github.com/workos/workos-go/v3)
[![Go Reference](https://pkg.go.dev/badge/github.com/workos/workos-go/v4.svg)](https://pkg.go.dev/github.com/workos/workos-go/v4)

The WorkOS library for Go provides convenient access to the WorkOS API from applications written in Go.

Expand All @@ -13,7 +13,7 @@ See the [API Reference](https://workos.com/docs/reference/client-libraries) for
Install the package with:

```
go get -u github.com/workos/workos-go/v3...
go get -u github.com/workos/workos-go/v4...
```

## Configuration
Expand All @@ -30,10 +30,10 @@ Or, you can set it on your own before your application starts:
sso.Configure(
"<WORKOS_API_KEY>",
"<CLIENT_ID>",
"https://foo-corp.com/redirect-uri",
)
"https://foo-corp.com/redirect-uri"
);

directorysync.SetAPIKey("<WORKOS_API_KEY>")
directorysync.SetAPIKey("<WORKOS_API_KEY>");
```

## SDK Versioning
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module github.com/workos/workos-go/v3
module github.com/workos/workos-go/v4

go 1.13

require (
github.com/google/go-querystring v1.0.0
github.com/google/uuid v1.1.1
github.com/stretchr/testify v1.6.1
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
2 changes: 1 addition & 1 deletion internal/workos/workos.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package workos

const (
// Version represents the SDK version number.
Version = "v3.2.0"
Version = "v4.0.0"
)
6 changes: 3 additions & 3 deletions pkg/auditlogs/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# auditlogs

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/auditlogs)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/auditlogs)

A Go package to send audit log events to WorkOS.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/auditlogs
go get -u github.com/workos/workos-go/v4/pkg/auditlogs
```

## How it works

```go
package main

import "github.com/workos/workos-go/v3/pkg/auditlogs"
import "github.com/workos/workos-go/v4/pkg/auditlogs"

func main() {
auditlogs.SetAPIKey("my_api_key")
Expand Down
4 changes: 2 additions & 2 deletions pkg/auditlogs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sync"
"time"

"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v4/internal/workos"
)

// ResponseLimit is the default number of records to limit a response to.
Expand Down
2 changes: 1 addition & 1 deletion pkg/auditlogs/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package auditlogs
import (
"context"
"encoding/json"
"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"
"net/http"
"net/http/httptest"
"testing"
Expand Down
4 changes: 2 additions & 2 deletions pkg/directorysync/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# directorysync

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/directorysync)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/directorysync)

A Go package to make requests to the WorkOS Directory Sync API.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/directorysync
go get -u github.com/workos/workos-go/v4/pkg/directorysync
```

## How it works
Expand Down
18 changes: 15 additions & 3 deletions pkg/directorysync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"time"

"github.com/google/go-querystring/query"
"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/internal/workos"
"github.com/workos/workos-go/v4/pkg/common"
)

// ResponseLimit is the default number of records to limit a response to.
Expand Down Expand Up @@ -189,6 +189,10 @@ func (c *Client) ListUsers(
opts.Limit = ResponseLimit
}

if opts.Order == "" {
opts.Order = Desc
}

v, err := query.Values(opts)
if err != nil {
return ListUsersResponse{}, err
Expand Down Expand Up @@ -295,6 +299,10 @@ func (c *Client) ListGroups(
opts.Limit = ResponseLimit
}

if opts.Order == "" {
opts.Order = Desc
}

v, err := query.Values(opts)
if err != nil {
return ListGroupsResponse{}, err
Expand Down Expand Up @@ -541,6 +549,10 @@ func (c *Client) ListDirectories(
opts.Limit = ResponseLimit
}

if opts.Order == "" {
opts.Order = Desc
}

v, err := query.Values(opts)
if err != nil {
return ListDirectoriesResponse{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/directorysync/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestListUsers(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/directorysync/directorysync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestDirectorySyncListUsers(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Go package to retrieve events from WorkOS.
## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/events
go get -u github.com/workos/workos-go/v4/pkg/events
```

## How it works
Expand All @@ -18,7 +18,7 @@ import (
"fmt"
"os"

"github.com/workos/workos-go/v3/pkg/events"
"github.com/workos/workos-go/v4/pkg/events"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/events/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"time"

"github.com/google/go-querystring/query"
"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/internal/workos"
"github.com/workos/workos-go/v4/pkg/common"
)

// ResponseLimit is the default number of records to limit a response to.
Expand Down
2 changes: 1 addition & 1 deletion pkg/events/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestListEvents(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestEventsListEvents(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/mfa/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"sync"
"time"

"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v4/internal/workos"
)

// This represents the list of errors that could be raised when using the mfa package
Expand Down
4 changes: 2 additions & 2 deletions pkg/organizations/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# organizations

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/organizations)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/organizations)

A Go package to make requests to the WorkOS Organizations API.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/organizations
go get -u github.com/workos/workos-go/v4/pkg/organizations
```

## How it works
Expand Down
10 changes: 7 additions & 3 deletions pkg/organizations/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"sync"
"time"

"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/google/go-querystring/query"
"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/internal/workos"
"github.com/workos/workos-go/v4/pkg/common"
)

// ResponseLimit is the default number of records to limit a response to.
Expand Down Expand Up @@ -225,6 +225,10 @@ func (c *Client) ListOrganizations(
opts.Limit = ResponseLimit
}

if opts.Order == "" {
opts.Order = Desc
}

q, err := query.Values(opts)
if err != nil {
return ListOrganizationsResponse{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/organizations/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestGetOrganization(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/organizations/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v3/pkg/common"
"github.com/workos/workos-go/v4/pkg/common"
)

func TestOrganizationsGetOrganization(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/passwordless/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# passwordless

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/passwordless)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/passwordless)

A Go package to make requests to the WorkOS Magic Link API.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/passwordless
go get -u github.com/workos/workos-go/v4/pkg/passwordless
```

## How it works
Expand Down
4 changes: 2 additions & 2 deletions pkg/passwordless/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"sync"
"time"

"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v4/internal/workos"
)

// Client represents a client that performs Passwordless requests to the WorkOS API.
Expand Down
4 changes: 2 additions & 2 deletions pkg/portal/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# portal

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/portal)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/portal)

A Go package to make requests to the WorkOS Admin Portal API.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/portal
go get -u github.com/workos/workos-go/v4/pkg/portal
```

## How it works
Expand Down
4 changes: 2 additions & 2 deletions pkg/portal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"sync"
"time"

"github.com/workos/workos-go/v3/pkg/workos_errors"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v3/internal/workos"
"github.com/workos/workos-go/v4/internal/workos"
)

// ResponseLimit is the default number of records to limit a response to.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sso/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# sso

[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v3/pkg/sso)
[![Go Report Card](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/workos/workos-go/v4/pkg/sso)

A go package to request WorkOS SSO API.

## Install

```sh
go get -u github.com/workos/workos-go/v3/pkg/sso
go get -u github.com/workos/workos-go/v4/pkg/sso
```

## How it works
Expand Down
Loading

0 comments on commit 7c8f3e3

Please sign in to comment.