/
configuration_service_esdk.pb.go
145 lines (113 loc) · 3.42 KB
/
configuration_service_esdk.pb.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Code generated by protoc-gen-go-esdk. DO NOT EDIT.
// See https://github.com/eolymp/contracts/tree/main/cmd/protoc-gen-go-esdk for more details.
package community
import (
bytes "bytes"
context "context"
fmt "fmt"
protojson "google.golang.org/protobuf/encoding/protojson"
proto "google.golang.org/protobuf/proto"
io "io"
ioutil "io/ioutil"
http "net/http"
url "net/url"
os "os"
)
type _ConfigurationServiceHttpClient interface {
Do(*http.Request) (*http.Response, error)
}
type ConfigurationServiceService struct {
base string
cli _ConfigurationServiceHttpClient
}
// NewConfigurationServiceHttpClient constructs client for ConfigurationService
func NewConfigurationServiceHttpClient(url string, cli _ConfigurationServiceHttpClient) *ConfigurationServiceService {
if url == "" {
url = os.Getenv("EOLYMP_API_URL")
if url == "" {
url = "https://api.eolymp.com"
}
}
return &ConfigurationServiceService{base: url, cli: cli}
}
func (s *ConfigurationServiceService) do(ctx context.Context, verb, path string, in, out proto.Message) (err error) {
var body io.Reader
if in != nil {
data, err := protojson.Marshal(in)
if err != nil {
return err
}
if verb != "GET" {
body = bytes.NewReader(data)
} else {
query := url.Values{"q": []string{string(data)}}
path = path + "?" + query.Encode()
}
}
if in == nil && verb != "GET" {
body = bytes.NewReader([]byte("{}"))
}
req, err := http.NewRequest(verb, s.base+path, body)
if err != nil {
return err
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req = req.WithContext(ctx)
resp, err := s.cli.Do(req)
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
if err != nil {
return err
}
if resp.StatusCode != 200 {
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("non-200 response code (%v)", resp.StatusCode)
}
return fmt.Errorf("non-200 response code (%v): %s", resp.StatusCode, data)
}
if out != nil {
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if err := protojson.Unmarshal(data, out); err != nil {
return err
}
}
return nil
}
func (s *ConfigurationServiceService) DescribeIdentityProvider(ctx context.Context, in *DescribeIdentityProviderInput) (*DescribeIdentityProviderOutput, error) {
out := &DescribeIdentityProviderOutput{}
path := "/idp"
if err := s.do(ctx, "GET", path, in, out); err != nil {
return nil, err
}
return out, nil
}
func (s *ConfigurationServiceService) ConfigureIdentityProvider(ctx context.Context, in *ConfigureIdentityProviderInput) (*ConfigureIdentityProviderOutput, error) {
out := &ConfigureIdentityProviderOutput{}
path := "/idp"
if err := s.do(ctx, "PUT", path, in, out); err != nil {
return nil, err
}
return out, nil
}
func (s *ConfigurationServiceService) DescribeIdentityConfig(ctx context.Context, in *DescribeIdentityConfigInput) (*DescribeIdentityConfigOutput, error) {
out := &DescribeIdentityConfigOutput{}
path := "/configs/identity"
if err := s.do(ctx, "GET", path, in, out); err != nil {
return nil, err
}
return out, nil
}
func (s *ConfigurationServiceService) ConfigureIdentityConfig(ctx context.Context, in *ConfigureIdentityConfigInput) (*ConfigureIdentityConfigOutput, error) {
out := &ConfigureIdentityConfigOutput{}
path := "/configs/identity"
if err := s.do(ctx, "PUT", path, in, out); err != nil {
return nil, err
}
return out, nil
}