Skip to content

Commit

Permalink
🌱 Add identity, proxy bindings and enable API tests (#311)
Browse files Browse the repository at this point in the history
Adding identity and proxy methods to binding package. Enabling Hub API
test execution on PRs ```Build Hub / test-api (pull_request)``` (in
disconnected mode).

Follow-up on #268

Signed-off-by: Marek Aufart <maufart@redhat.com>
  • Loading branch information
aufi authored May 6, 2023
1 parent 122ec48 commit cdb5514
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 12 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ jobs:
go-version: '1.19'
- run: make test

#test-api:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '1.19'
# - run: |
# make vet
# make run &
# sleep 15 # probably a dirty solution
# HUB_BASE_URL=http://localhost:8080 make test-api
test-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- run: |
make vet
DISCONNECTED=1 make run &
sleep 15 # probably a dirty solution
HUB_BASE_URL=http://localhost:8080 make test-api
test-e2e:
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions binding/identity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package binding

import (
"github.com/konveyor/tackle2-hub/api"
)

//
// Identity API.
type Identity struct {
// hub API client.
client *Client
}

//
// Create a Identity.
func (h *Identity) Create(r *api.Identity) (err error) {
err = h.client.Post(api.IdentitiesRoot, &r)
return
}

//
// Get a Identity by ID.
func (h *Identity) Get(id uint) (r *api.Identity, err error) {
r = &api.Identity{}
path := Path(api.IdentityRoot).Inject(Params{api.ID: id})
err = h.client.Get(path, r)
return
}

//
// List Identities.
func (h *Identity) List() (list []api.Identity, err error) {
list = []api.Identity{}
err = h.client.Get(api.IdentitiesRoot, &list)
return
}

//
// Update a Identity.
func (h *Identity) Update(r *api.Identity) (err error) {
path := Path(api.IdentityRoot).Inject(Params{api.ID: r.ID})
err = h.client.Put(path, r)
return
}

//
// Delete a Identity.
func (h *Identity) Delete(id uint) (err error) {
err = h.client.Delete(Path(api.IdentityRoot).Inject(Params{api.ID: id}))
return
}
51 changes: 51 additions & 0 deletions binding/proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package binding

import (
"github.com/konveyor/tackle2-hub/api"
)

//
// Proxy API.
type Proxy struct {
// hub API client.
client *Client
}

//
// Create a Proxy.
func (h *Proxy) Create(r *api.Proxy) (err error) {
err = h.client.Post(api.ProxiesRoot, &r)
return
}

//
// Get a Proxy by ID.
func (h *Proxy) Get(id uint) (r *api.Proxy, err error) {
r = &api.Proxy{}
path := Path(api.ProxyRoot).Inject(Params{api.ID: id})
err = h.client.Get(path, r)
return
}

//
// List Proxies.
func (h *Proxy) List() (list []api.Proxy, err error) {
list = []api.Proxy{}
err = h.client.Get(api.ProxiesRoot, &list)
return
}

//
// Update a Proxy.
func (h *Proxy) Update(r *api.Proxy) (err error) {
path := Path(api.ProxyRoot).Inject(Params{api.ID: r.ID})
err = h.client.Put(path, r)
return
}

//
// Delete a Proxy.
func (h *Proxy) Delete(id uint) (err error) {
err = h.client.Delete(Path(api.ProxyRoot).Inject(Params{api.ID: id}))
return
}
8 changes: 8 additions & 0 deletions binding/richclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ type RichClient struct {
// Resources APIs.
Application Application
BusinessService BusinessService
Identity Identity
JobFunction JobFunction
Proxy Proxy
Stakeholder Stakeholder
StakeholderGroup StakeholderGroup
Tag Tag
Expand Down Expand Up @@ -54,9 +56,15 @@ func New(baseUrl string) (r *RichClient) {
BusinessService: BusinessService{
client: client,
},
Identity: Identity{
client: client,
},
JobFunction: JobFunction{
client: client,
},
Proxy: Proxy{
client: client,
},
Stakeholder: Stakeholder{
client: client,
},
Expand Down

0 comments on commit cdb5514

Please sign in to comment.