-
Notifications
You must be signed in to change notification settings - Fork 2
/
authentication_read.go
71 lines (63 loc) · 2.15 KB
/
authentication_read.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
package iis
import (
"context"
"fmt"
)
type Authentication struct {
ID string `json:"id"`
Links AuthenticationLinks `json:"_links"`
}
type AuthenticationLinks struct {
Anonymous ResourceReference `json:"anonymous"`
Basic ResourceReference `json:"basic"`
Digest ResourceReference `json:"digest"`
Windows ResourceReference `json:"windows"`
}
func (client Client) ReadAuthentication(ctx context.Context, id string) (Authentication, error) {
url := fmt.Sprintf("/api/webserver/authentication/%s", id)
var auth Authentication
if err := getJson(ctx, client, url, &auth); err != nil {
return auth, err
}
return auth, nil
}
func (client Client) ReadAuthenticationFromApplication(ctx context.Context, applicationId string) (Authentication, error) {
var auth Authentication
application, err := client.ReadApplication(ctx, applicationId)
if err != nil {
return auth, err
}
url := application.Links["authentication"].Href
if err := getJson(ctx, client, url, &auth); err != nil {
return auth, err
}
return auth, nil
}
func (client Client) ReadAnonymousAuthentication(ctx context.Context, auth *Authentication) (AnonymousAuthentication, error) {
var anonymous AnonymousAuthentication
if err := getJson(ctx, client, auth.Links.Anonymous.Href, &anonymous); err != nil {
return anonymous, err
}
return anonymous, nil
}
func (client Client) ReadBasicAuthentication(ctx context.Context, auth *Authentication) (BasicAuthentication, error) {
var basic BasicAuthentication
if err := getJson(ctx, client, auth.Links.Basic.Href, &basic); err != nil {
return basic, err
}
return basic, nil
}
func (client Client) ReadDigestAuthentication(ctx context.Context, auth *Authentication) (DigestAuthentication, error) {
var digest DigestAuthentication
if err := getJson(ctx, client, auth.Links.Digest.Href, &digest); err != nil {
return digest, err
}
return digest, nil
}
func (client Client) ReadWindowsAuthentication(ctx context.Context, auth *Authentication) (WindowsAuthentication, error) {
var windows WindowsAuthentication
if err := getJson(ctx, client, auth.Links.Windows.Href, &windows); err != nil {
return windows, err
}
return windows, nil
}