forked from cloudfoundry/go-uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generated_mfaprovider.go
80 lines (72 loc) · 2.29 KB
/
generated_mfaprovider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Code generated by go-uaa/generator; DO NOT EDIT.
package uaa
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
)
// GetMFAProvider with the given mfaproviderID.
func (a *API) GetMFAProvider(mfaproviderID string) (*MFAProvider, error) {
u := urlWithPath(*a.TargetURL, fmt.Sprintf("%s/%s", MFAProvidersEndpoint, mfaproviderID))
mfaprovider := &MFAProvider{}
err := a.doJSON(http.MethodGet, &u, nil, mfaprovider, true)
if err != nil {
return nil, err
}
return mfaprovider, nil
}
// CreateMFAProvider creates the given mfaprovider.
func (a *API) CreateMFAProvider(mfaprovider MFAProvider) (*MFAProvider, error) {
u := urlWithPath(*a.TargetURL, MFAProvidersEndpoint)
created := &MFAProvider{}
j, err := json.Marshal(mfaprovider)
if err != nil {
return nil, err
}
err = a.doJSON(http.MethodPost, &u, bytes.NewBuffer([]byte(j)), created, true)
if err != nil {
return nil, err
}
return created, nil
}
// UpdateMFAProvider updates the given mfaprovider.
func (a *API) UpdateMFAProvider(mfaprovider MFAProvider) (*MFAProvider, error) {
u := urlWithPath(*a.TargetURL, fmt.Sprintf("%s/%s", MFAProvidersEndpoint, mfaprovider.Identifier()))
created := &MFAProvider{}
j, err := json.Marshal(mfaprovider)
if err != nil {
return nil, err
}
err = a.doJSON(http.MethodPut, &u, bytes.NewBuffer([]byte(j)), created, true)
if err != nil {
return nil, err
}
return created, nil
}
// DeleteMFAProvider deletes the mfaprovider with the given mfaprovider ID.
func (a *API) DeleteMFAProvider(mfaproviderID string) (*MFAProvider, error) {
if mfaproviderID == "" {
return nil, errors.New("mfaproviderID cannot be blank")
}
u := urlWithPath(*a.TargetURL, fmt.Sprintf("%s/%s", MFAProvidersEndpoint, mfaproviderID))
deleted := &MFAProvider{}
err := a.doJSON(http.MethodDelete, &u, nil, deleted, true)
if err != nil {
return nil, err
}
return deleted, nil
}
// ListMFAProviders fetches all of the MFAProvider records.
// If successful, ListMFAProviders returns the mfaproviders
// If unsuccessful, ListMFAProviders returns the error.
func (a *API) ListMFAProviders() ([]MFAProvider, error) {
u := urlWithPath(*a.TargetURL, MFAProvidersEndpoint)
var mfaproviders []MFAProvider
err := a.doJSON(http.MethodGet, &u, nil, &mfaproviders, true)
if err != nil {
return nil, err
}
return mfaproviders, nil
}