github.com/openshift-online/ocm-sdk-go@v0.1.473/authorizations/v1/export_control_review_client.go (about) 1 /* 2 Copyright (c) 2020 Red Hat, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all 18 // your changes will be lost when the file is generated again. 19 20 package v1 // github.com/openshift-online/ocm-sdk-go/authorizations/v1 21 22 import ( 23 "bufio" 24 "bytes" 25 "context" 26 "io" 27 "net/http" 28 "net/url" 29 30 "github.com/openshift-online/ocm-sdk-go/errors" 31 "github.com/openshift-online/ocm-sdk-go/helpers" 32 ) 33 34 // ExportControlReviewClient is the client of the 'export_control_review' resource. 35 // 36 // Manages export control review. 37 type ExportControlReviewClient struct { 38 transport http.RoundTripper 39 path string 40 } 41 42 // NewExportControlReviewClient creates a new client for the 'export_control_review' 43 // resource using the given transport to send the requests and receive the 44 // responses. 45 func NewExportControlReviewClient(transport http.RoundTripper, path string) *ExportControlReviewClient { 46 return &ExportControlReviewClient{ 47 transport: transport, 48 path: path, 49 } 50 } 51 52 // Post creates a request for the 'post' method. 53 // 54 // Screens a user by account user name. 55 func (c *ExportControlReviewClient) Post() *ExportControlReviewPostRequest { 56 return &ExportControlReviewPostRequest{ 57 transport: c.transport, 58 path: c.path, 59 } 60 } 61 62 // ExportControlReviewPostRequest is the request for the 'post' method. 63 type ExportControlReviewPostRequest struct { 64 transport http.RoundTripper 65 path string 66 query url.Values 67 header http.Header 68 request *ExportControlReviewRequest 69 } 70 71 // Parameter adds a query parameter. 72 func (r *ExportControlReviewPostRequest) Parameter(name string, value interface{}) *ExportControlReviewPostRequest { 73 helpers.AddValue(&r.query, name, value) 74 return r 75 } 76 77 // Header adds a request header. 78 func (r *ExportControlReviewPostRequest) Header(name string, value interface{}) *ExportControlReviewPostRequest { 79 helpers.AddHeader(&r.header, name, value) 80 return r 81 } 82 83 // Impersonate wraps requests on behalf of another user. 84 // Note: Services that do not support this feature may silently ignore this call. 85 func (r *ExportControlReviewPostRequest) Impersonate(user string) *ExportControlReviewPostRequest { 86 helpers.AddImpersonationHeader(&r.header, user) 87 return r 88 } 89 90 // Request sets the value of the 'request' parameter. 91 func (r *ExportControlReviewPostRequest) Request(value *ExportControlReviewRequest) *ExportControlReviewPostRequest { 92 r.request = value 93 return r 94 } 95 96 // Send sends this request, waits for the response, and returns it. 97 // 98 // This is a potentially lengthy operation, as it requires network communication. 99 // Consider using a context and the SendContext method. 100 func (r *ExportControlReviewPostRequest) Send() (result *ExportControlReviewPostResponse, err error) { 101 return r.SendContext(context.Background()) 102 } 103 104 // SendContext sends this request, waits for the response, and returns it. 105 func (r *ExportControlReviewPostRequest) SendContext(ctx context.Context) (result *ExportControlReviewPostResponse, err error) { 106 query := helpers.CopyQuery(r.query) 107 header := helpers.CopyHeader(r.header) 108 buffer := &bytes.Buffer{} 109 err = writeExportControlReviewPostRequest(r, buffer) 110 if err != nil { 111 return 112 } 113 uri := &url.URL{ 114 Path: r.path, 115 RawQuery: query.Encode(), 116 } 117 request := &http.Request{ 118 Method: "POST", 119 URL: uri, 120 Header: header, 121 Body: io.NopCloser(buffer), 122 } 123 if ctx != nil { 124 request = request.WithContext(ctx) 125 } 126 response, err := r.transport.RoundTrip(request) 127 if err != nil { 128 return 129 } 130 defer response.Body.Close() 131 result = &ExportControlReviewPostResponse{} 132 result.status = response.StatusCode 133 result.header = response.Header 134 reader := bufio.NewReader(response.Body) 135 _, err = reader.Peek(1) 136 if err == io.EOF { 137 err = nil 138 return 139 } 140 if result.status >= 400 { 141 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 142 if err != nil { 143 return 144 } 145 err = result.err 146 return 147 } 148 err = readExportControlReviewPostResponse(result, reader) 149 if err != nil { 150 return 151 } 152 return 153 } 154 155 // ExportControlReviewPostResponse is the response for the 'post' method. 156 type ExportControlReviewPostResponse struct { 157 status int 158 header http.Header 159 err *errors.Error 160 response *ExportControlReviewResponse 161 } 162 163 // Status returns the response status code. 164 func (r *ExportControlReviewPostResponse) Status() int { 165 if r == nil { 166 return 0 167 } 168 return r.status 169 } 170 171 // Header returns header of the response. 172 func (r *ExportControlReviewPostResponse) Header() http.Header { 173 if r == nil { 174 return nil 175 } 176 return r.header 177 } 178 179 // Error returns the response error. 180 func (r *ExportControlReviewPostResponse) Error() *errors.Error { 181 if r == nil { 182 return nil 183 } 184 return r.err 185 } 186 187 // Response returns the value of the 'response' parameter. 188 func (r *ExportControlReviewPostResponse) Response() *ExportControlReviewResponse { 189 if r == nil { 190 return nil 191 } 192 return r.response 193 } 194 195 // GetResponse returns the value of the 'response' parameter and 196 // a flag indicating if the parameter has a value. 197 func (r *ExportControlReviewPostResponse) GetResponse() (value *ExportControlReviewResponse, ok bool) { 198 ok = r != nil && r.response != nil 199 if ok { 200 value = r.response 201 } 202 return 203 }