Skip to content

Commit

Permalink
release 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Feb 3, 2021
1 parent 1efbf18 commit 7b37516
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.5.0] - Feb 03, 2021

### Added

- Developer Account endpoints [#40](https://github.com/3scale/3scale-porta-go-client/pull/40)
- Developer User endpoints [#41](https://github.com/3scale/3scale-porta-go-client/pull/41)

## [0.4.0] - Dev 10, 2020

### Added

- Policy Registry endpoints [#39](https://github.com/3scale/3scale-porta-go-client/pull/39)

## [0.3.0] - Dev 04, 2020

### Added

- ActiveDocs endpoints [#38](https://github.com/3scale/3scale-porta-go-client/pull/38)

## [0.2.0] - Nov 23, 2020

### Added

- Oidc configuration endpoints [#35](https://github.com/3scale/3scale-porta-go-client/pull/35)
- Add proxy type fields for oidc authorization [#36](https://github.com/3scale/3scale-porta-go-client/pull/36)
- Product read endpoint [#37](https://github.com/3scale/3scale-porta-go-client/pull/37)

## [0.1.0] - Nov 16, 2020

[Unreleased]: https://github.com/3scale/3scale-porta-go-client/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/3scale/3scale-porta-go-client/releases/tag/v0.5.0
[0.4.0]: https://github.com/3scale/3scale-porta-go-client/releases/tag/v0.4.0
[0.3.0]: https://github.com/3scale/3scale-porta-go-client/releases/tag/v0.3.0
[0.2.0]: https://github.com/3scale/3scale-porta-go-client/releases/tag/v0.2.0
[0.1.0]: https://github.com/3scale/3scale-porta-go-client/releases/tag/v0.1.0
131 changes: 131 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,133 @@
# 3scale-porta-go-client
[![CircleCI](https://circleci.com/gh/3scale/3scale-porta-go-client.svg?style=svg)](https://circleci.com/gh/3scale/3scale-porta-go-client)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![GitHub release](https://img.shields.io/github/v/release/3scale/3scale-porta-go-client.svg)](https://github.com/3scale/3scale-porta-go-client/releases/latest)

3scale Account Management API Client

## Installation

To install, run:

```bash
$ go get github.com/3scale/3scale-porta-go-client/client
```

And import using:

```go
import "github.com/3scale/3scale-porta-go-client/client"
```

## Usage

Basic usage

```go
package main

import (
"encoding/json"
"fmt"

"github.com/3scale/3scale-porta-go-client/client"
)

func jsonPrint(obj interface{}) {
jsonData, err := json.MarshalIndent(obj, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
}

func main() {
adminPortalURL := "https://3scale-admin.example.com"
threescaleAccessToken := "************************"

adminPortal, err := client.NewAdminPortalFromStr(adminPortalURL)
if err != nil {
fmt.Printf("%+v\n", err)
return
}

threescaleClient := client.NewThreeScale(adminPortal, threescaleAccessToken, nil)

backendList, err := threescaleClient.ListBackendApis()
if err != nil {
fmt.Printf("%+v\n", err)
return
}

jsonPrint(backendList)
}
```

The `client.NewThreeScale` constructor allows injecting you own customized [\*http.Client](https://golang.org/src/net/http/client.go).

In this example, the customized transport will log all http requests and responses

```go
type DebuggerTransport struct {
Transport http.RoundTripper
}

// RoundTrip is the core part of this module and implements http.RoundTripper.
// Executes HTTP request with request/response logging.
func (t *DebuggerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
t.logRequest(req)

resp, err := t.transport().RoundTrip(req)
if err != nil {
return resp, err
}

t.logResponse(resp)

return resp, err
}

func (t *DebuggerTransport) logRequest(req *http.Request) {
dump, _ := httputil.DumpRequestOut(req, true)
fmt.Println(string(dump))
}

func (t *DebuggerTransport) logResponse(resp *http.Response) {
dump, _ := httputil.DumpResponse(resp, true)
fmt.Println(string(dump))
}

func (t *DebuggerTransport) transport() http.RoundTripper {
if t.Transport != nil {
return t.Transport
}

return http.DefaultTransport
}

var transport http.RoundTripper = &DebuggerTransport{}

threescaleClient := client.NewThreeScale(adminPortal, threescaleAccessToken, &http.Client{Transport: transport})
```

In this example, the customized transport allow insecure TLS connections (**warning**: this use is not recommended)

```go
var transport http.RoundTripper = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}

threescaleClient := client.NewThreeScale(adminPortal, threescaleAccessToken, &http.Client{Transport: transport})
```

## Development

### Testing

```
$ make test
```

## Contributing

Bug reports and pull requests are welcome on [GitHub](https://github.com/3scale/3scale-porta-go-client)

0 comments on commit 7b37516

Please sign in to comment.