Skip to content

Commit

Permalink
Include authress.company.com in documentation examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Feb 4, 2024
1 parent 0b7bdf8 commit 1df3c19
Show file tree
Hide file tree
Showing 32 changed files with 450 additions and 207 deletions.
44 changes: 10 additions & 34 deletions apis/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import (
. "github.com/authress/authress-sdk.go/utilities"
)

type HttpClient struct {
ClientConfiguration *Configuration
InternalClient *http.Client
}

var (
JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]")
)

type HttpClient struct {
ClientConfiguration *Configuration
InternalClient *http.Client
}

func atoi(in string) (int, error) {
return strconv.Atoi(in)
}
Expand Down Expand Up @@ -354,7 +354,9 @@ func (c *HttpClient) prepareRequest(
}

// Add the user agent to the request.
localVarRequest.Header.Add("User-Agent", c.ClientConfiguration.UserAgent)
version := c.ClientConfiguration.Version
serviceName := c.ClientConfiguration.UserAgent
localVarRequest.Header.Add("User-Agent", fmt.Sprintf("Authress SDK; Go; %s; %s", version, serviceName))

if ctx != nil {
// add context to the request
Expand Down Expand Up @@ -662,37 +664,16 @@ type ServerConfigurations []ServerConfiguration

// Configuration stores the configuration of the API client
type Configuration struct {
Version string `json:"version,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Debug bool `json:"debug,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Servers ServerConfigurations
OperationServers map[string]ServerConfigurations
}

// NewConfiguration returns a new Configuration object
func NewConfiguration() *Configuration {
ClientConfiguration := &Configuration{
DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/99.99.99/go",
Debug: false,
Servers: ServerConfigurations{
{
URL: "",
Description: "No description provided",
},
},
OperationServers: map[string]ServerConfigurations{},
}
return ClientConfiguration
}

// AddDefaultHeader adds a new HTTP header to the default header in the request
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}

// URL formats template on a index using given variables
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
if index < 0 || len(sc) <= index {
Expand Down Expand Up @@ -721,11 +702,6 @@ func (sc ServerConfigurations) URL(index int, variables map[string]string) (stri
return url, nil
}

// ServerURL returns URL based on server settings
func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
return c.Servers.URL(index, variables)
}

func getServerIndex(ctx context.Context) (int, error) {
si := ctx.Value(ContextServerIndex)
if si != nil {
Expand Down
8 changes: 7 additions & 1 deletion authress.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ type AuthressClient struct {
}

// New creates a new Authress API client.
func New(authressSettings *AuthressSettings) *AuthressClient {
func NewAuthressClient(authressSettings AuthressSettings) *AuthressClient {
httpClient := HttpClient{
InternalClient: http.DefaultClient,
ClientConfiguration: &Configuration{
Version: GetBuildInfo().Version,
UserAgent: authressSettings.UserAgent,
Scheme: authressSettings.AuthressApiUrl.Scheme,
Host: authressSettings.AuthressApiUrl.Host,
},
}

authressClient := AuthressClient{
Expand Down
9 changes: 7 additions & 2 deletions authress_settings.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package authress

import (
"net/url"
)

type AuthressSettings struct {
AuthressApiUrl string
service_client_access_key string
AuthressApiUrl *url.URL
ServiceClientAccessKey string
UserAgent string
}
4 changes: 3 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ podman stop $CID && podman rm $CID
* [ ] Remove LocalHost from the docs
* [ ] Tests
* [ ] If-unmodified-since should called `expectedLastModifiedTime`, accept string or dateTime and convert this to an ISO String
* [ ] Update OAuth2 openapi authentication references in the documentation
* [ ] Update OAuth2 openapi authentication references in the documentation
* [x] Find all incorrect references to version 99.99.99
* [x] Inject in the User-Agent
55 changes: 44 additions & 11 deletions docs/AccessRecordsAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import (
func main() {
claimRequest := *authress.NewClaimRequest("CollectionResource_example", "ResourceId_example") // ClaimRequest |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.CreateClaim(context.Background()).ClaimRequest(claimRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.CreateClaim``: %v\n", err)
Expand Down Expand Up @@ -100,7 +103,10 @@ import (
func main() {
accessRecord := *authress.NewAccessRecord("Name_example", []authress.Statement{*authress.NewStatement([]string{"Roles_example"}, []authress.Resource{*authress.NewResource("/organizations/org_a/documents/doc_1")})}) // AccessRecord |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.CreateRecord(context.Background()).AccessRecord(accessRecord).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.CreateRecord``: %v\n", err)
Expand Down Expand Up @@ -161,7 +167,10 @@ import (
func main() {
accessRequest := *authress.NewAccessRequest("RequestId_example", *authress.NewAccessTemplate([]authress.User{*authress.NewUser("oauth|userId")}, []authress.Statement{*authress.NewStatement([]string{"Roles_example"}, []authress.Resource{*authress.NewResource("/organizations/org_a/documents/doc_1")})})) // AccessRequest |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.CreateRequest(context.Background()).AccessRequest(accessRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.CreateRequest``: %v\n", err)
Expand Down Expand Up @@ -222,7 +231,10 @@ import (
func main() {
recordId := "recordId_example" // string | The identifier of the access record.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
r, err := apiClient.AccessRecords.DeleteRecord(context.Background(), recordId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.DeleteRecord``: %v\n", err)
Expand Down Expand Up @@ -285,7 +297,10 @@ import (
func main() {
requestId := "requestId_example" // string | The identifier of the access request.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
r, err := apiClient.AccessRecords.DeleteRequest(context.Background(), requestId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.DeleteRequest``: %v\n", err)
Expand Down Expand Up @@ -348,7 +363,10 @@ import (
func main() {
recordId := "recordId_example" // string | The identifier of the access record.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.GetRecord(context.Background(), recordId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.GetRecord``: %v\n", err)
Expand Down Expand Up @@ -416,7 +434,10 @@ func main() {
filter := "filter_example" // string | Filter to search records by. This is a case insensitive search through every text field. (optional)
status := "status_example" // string | Filter records by their current status. (optional)

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.GetRecords(context.Background()).Limit(limit).Cursor(cursor).Filter(filter).Status(status).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.GetRecords``: %v\n", err)
Expand Down Expand Up @@ -480,7 +501,10 @@ import (
func main() {
requestId := "requestId_example" // string | The identifier of the access request.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.GetRequest(context.Background(), requestId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.GetRequest``: %v\n", err)
Expand Down Expand Up @@ -547,7 +571,10 @@ func main() {
cursor := "cursor_example" // string | Continuation cursor for paging (optional)
status := "status_example" // string | Filter requests by their current status. (optional)

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.GetRequests(context.Background()).Limit(limit).Cursor(cursor).Status(status).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.GetRequests``: %v\n", err)
Expand Down Expand Up @@ -611,7 +638,10 @@ func main() {
requestId := "requestId_example" // string | The identifier of the access request.
accessRequestResponse := *authress.NewAccessRequestResponse("Status_example") // AccessRequestResponse |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.AccessRecords.RespondToAccessRequest(context.Background(), requestId).AccessRequestResponse(accessRequestResponse).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.RespondToAccessRequest``: %v\n", err)
Expand Down Expand Up @@ -680,7 +710,10 @@ func main() {
accessRecord := *authress.NewAccessRecord("Name_example", []authress.Statement{*authress.NewStatement([]string{"Roles_example"}, []authress.Resource{*authress.NewResource("/organizations/org_a/documents/doc_1")})}) // AccessRecord |
ifUnmodifiedSince := time.Now() // time.Time | The expected last time the record was modified. (optional)

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
r, err := apiClient.AccessRecords.UpdateRecord(context.Background(), recordId).AccessRecord(accessRecord).IfUnmodifiedSince(ifUnmodifiedSince).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AccessRecords.UpdateRecord``: %v\n", err)
Expand Down
20 changes: 16 additions & 4 deletions docs/AccountsAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import (
func main() {
identityRequest := *authress.NewIdentityRequest() // IdentityRequest |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
r, err := apiClient.Accounts.DelegateAuthentication(context.Background()).IdentityRequest(identityRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Accounts.DelegateAuthentication``: %v\n", err)
Expand Down Expand Up @@ -91,7 +94,10 @@ import (
func main() {
accountId := "accountId_example" // string | The unique identifier for the account

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Accounts.GetAccount(context.Background(), accountId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Accounts.GetAccount``: %v\n", err)
Expand Down Expand Up @@ -155,7 +161,10 @@ import (

func main() {

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Accounts.GetAccountIdentities(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Accounts.GetAccountIdentities``: %v\n", err)
Expand Down Expand Up @@ -213,7 +222,10 @@ import (
func main() {
earliestCacheTime := time.Now() // time.Time | Ensure the accounts list is not cached before this time. (optional)

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Accounts.GetAccounts(context.Background()).EarliestCacheTime(earliestCacheTime).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Accounts.GetAccounts``: %v\n", err)
Expand Down
5 changes: 4 additions & 1 deletion docs/ApplicationsAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func main() {
applicationId := "applicationId_example" // string | The application to have the user log into.
userId := TODO // UserId | The user.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Applications.DelegateUserLogin(context.Background(), applicationId, userId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Applications.DelegateUserLogin``: %v\n", err)
Expand Down
30 changes: 24 additions & 6 deletions docs/ConnectionsAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import (
func main() {
connection := *authress.NewConnection() // Connection |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Connections.CreateConnection(context.Background()).Connection(connection).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.CreateConnection``: %v\n", err)
Expand Down Expand Up @@ -95,7 +98,10 @@ import (
func main() {
connectionId := "connectionId_example" // string | The connection identifier.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
r, err := apiClient.Connections.DeleteConnection(context.Background(), connectionId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.DeleteConnection``: %v\n", err)
Expand Down Expand Up @@ -158,7 +164,10 @@ import (
func main() {
connectionId := "connectionId_example" // string | The connection identifier.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Connections.GetConnection(context.Background(), connectionId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.GetConnection``: %v\n", err)
Expand Down Expand Up @@ -224,7 +233,10 @@ func main() {
connectionId := "connectionId_example" // string | The connection identifier.
userId := TODO // UserId | The connection user.

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Connections.GetConnectionCredentials(context.Background(), connectionId, userId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.GetConnectionCredentials``: %v\n", err)
Expand Down Expand Up @@ -290,7 +302,10 @@ import (

func main() {

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Connections.GetConnections(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.GetConnections``: %v\n", err)
Expand Down Expand Up @@ -348,7 +363,10 @@ func main() {
connectionId := "connectionId_example" // string | The connection identifier.
connection := *authress.NewConnection() // Connection |

authressClient := authress.AuthressClient.New(authress.AuthressSettings {})
url, _ := url.Parse("https://authress.company.com")
authressClient := authress.NewAuthressClient(authress.AuthressSettings{
AuthressApiUrl: url,
})
resp, r, err := apiClient.Connections.UpdateConnection(context.Background(), connectionId).Connection(connection).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Connections.UpdateConnection``: %v\n", err)
Expand Down
Loading

0 comments on commit 1df3c19

Please sign in to comment.