github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/awssts_policies_inquiry_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/clustersmgmt/v1
    21  
    22  import (
    23  	"bufio"
    24  	"context"
    25  	"io"
    26  	"net/http"
    27  	"net/url"
    28  
    29  	"github.com/openshift-online/ocm-sdk-go/errors"
    30  	"github.com/openshift-online/ocm-sdk-go/helpers"
    31  )
    32  
    33  // AWSSTSPoliciesInquiryClient is the client of the 'AWSSTS_policies_inquiry' resource.
    34  //
    35  // Manages STS policies
    36  type AWSSTSPoliciesInquiryClient struct {
    37  	transport http.RoundTripper
    38  	path      string
    39  }
    40  
    41  // NewAWSSTSPoliciesInquiryClient creates a new client for the 'AWSSTS_policies_inquiry'
    42  // resource using the given transport to send the requests and receive the
    43  // responses.
    44  func NewAWSSTSPoliciesInquiryClient(transport http.RoundTripper, path string) *AWSSTSPoliciesInquiryClient {
    45  	return &AWSSTSPoliciesInquiryClient{
    46  		transport: transport,
    47  		path:      path,
    48  	}
    49  }
    50  
    51  // List creates a request for the 'list' method.
    52  //
    53  // Retrieves the list of policies.
    54  func (c *AWSSTSPoliciesInquiryClient) List() *AWSSTSPoliciesInquiryListRequest {
    55  	return &AWSSTSPoliciesInquiryListRequest{
    56  		transport: c.transport,
    57  		path:      c.path,
    58  	}
    59  }
    60  
    61  // AWSSTSPoliciesInquiryListRequest is the request for the 'list' method.
    62  type AWSSTSPoliciesInquiryListRequest struct {
    63  	transport http.RoundTripper
    64  	path      string
    65  	query     url.Values
    66  	header    http.Header
    67  	order     *string
    68  	page      *int
    69  	search    *string
    70  	size      *int
    71  }
    72  
    73  // Parameter adds a query parameter.
    74  func (r *AWSSTSPoliciesInquiryListRequest) Parameter(name string, value interface{}) *AWSSTSPoliciesInquiryListRequest {
    75  	helpers.AddValue(&r.query, name, value)
    76  	return r
    77  }
    78  
    79  // Header adds a request header.
    80  func (r *AWSSTSPoliciesInquiryListRequest) Header(name string, value interface{}) *AWSSTSPoliciesInquiryListRequest {
    81  	helpers.AddHeader(&r.header, name, value)
    82  	return r
    83  }
    84  
    85  // Impersonate wraps requests on behalf of another user.
    86  // Note: Services that do not support this feature may silently ignore this call.
    87  func (r *AWSSTSPoliciesInquiryListRequest) Impersonate(user string) *AWSSTSPoliciesInquiryListRequest {
    88  	helpers.AddImpersonationHeader(&r.header, user)
    89  	return r
    90  }
    91  
    92  // Order sets the value of the 'order' parameter.
    93  //
    94  // Order criteria.
    95  //
    96  // The syntax of this parameter is similar to the syntax of the _order by_ clause of
    97  // a SQL statement, but using the names of the attributes of the awsstspolicies instead of
    98  // the names of the columns of a table. For example, in order to sort the policies
    99  // descending by operator type identifier the value should be:
   100  //
   101  // ```sql
   102  // orderBy id desc
   103  // ```
   104  //
   105  // If the parameter isn't provided, or if the value is empty, then the order of the
   106  // results is undefined.
   107  func (r *AWSSTSPoliciesInquiryListRequest) Order(value string) *AWSSTSPoliciesInquiryListRequest {
   108  	r.order = &value
   109  	return r
   110  }
   111  
   112  // Page sets the value of the 'page' parameter.
   113  //
   114  // Index of the requested page, where one corresponds to the first page.
   115  func (r *AWSSTSPoliciesInquiryListRequest) Page(value int) *AWSSTSPoliciesInquiryListRequest {
   116  	r.page = &value
   117  	return r
   118  }
   119  
   120  // Search sets the value of the 'search' parameter.
   121  //
   122  // Search criteria.
   123  //
   124  // The syntax of this parameter is similar to the syntax of the _where_ clause of a
   125  // SQL statement, but using the names of the attributes of the awsstspolicies instead of
   126  // the names of the columns of a table. For example, in order to retrieve all the
   127  // policies of type  `operatorrole`
   128  // should be:
   129  //
   130  // ```sql
   131  // policy_type like 'OperatorRole%'
   132  // ```
   133  //
   134  // If the parameter isn't provided, or if the value is empty, then all the
   135  // policies  will be returned.
   136  func (r *AWSSTSPoliciesInquiryListRequest) Search(value string) *AWSSTSPoliciesInquiryListRequest {
   137  	r.search = &value
   138  	return r
   139  }
   140  
   141  // Size sets the value of the 'size' parameter.
   142  //
   143  // Maximum number of items that will be contained in the returned page.
   144  func (r *AWSSTSPoliciesInquiryListRequest) Size(value int) *AWSSTSPoliciesInquiryListRequest {
   145  	r.size = &value
   146  	return r
   147  }
   148  
   149  // Send sends this request, waits for the response, and returns it.
   150  //
   151  // This is a potentially lengthy operation, as it requires network communication.
   152  // Consider using a context and the SendContext method.
   153  func (r *AWSSTSPoliciesInquiryListRequest) Send() (result *AWSSTSPoliciesInquiryListResponse, err error) {
   154  	return r.SendContext(context.Background())
   155  }
   156  
   157  // SendContext sends this request, waits for the response, and returns it.
   158  func (r *AWSSTSPoliciesInquiryListRequest) SendContext(ctx context.Context) (result *AWSSTSPoliciesInquiryListResponse, err error) {
   159  	query := helpers.CopyQuery(r.query)
   160  	if r.order != nil {
   161  		helpers.AddValue(&query, "order", *r.order)
   162  	}
   163  	if r.page != nil {
   164  		helpers.AddValue(&query, "page", *r.page)
   165  	}
   166  	if r.search != nil {
   167  		helpers.AddValue(&query, "search", *r.search)
   168  	}
   169  	if r.size != nil {
   170  		helpers.AddValue(&query, "size", *r.size)
   171  	}
   172  	header := helpers.CopyHeader(r.header)
   173  	uri := &url.URL{
   174  		Path:     r.path,
   175  		RawQuery: query.Encode(),
   176  	}
   177  	request := &http.Request{
   178  		Method: "GET",
   179  		URL:    uri,
   180  		Header: header,
   181  	}
   182  	if ctx != nil {
   183  		request = request.WithContext(ctx)
   184  	}
   185  	response, err := r.transport.RoundTrip(request)
   186  	if err != nil {
   187  		return
   188  	}
   189  	defer response.Body.Close()
   190  	result = &AWSSTSPoliciesInquiryListResponse{}
   191  	result.status = response.StatusCode
   192  	result.header = response.Header
   193  	reader := bufio.NewReader(response.Body)
   194  	_, err = reader.Peek(1)
   195  	if err == io.EOF {
   196  		err = nil
   197  		return
   198  	}
   199  	if result.status >= 400 {
   200  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   201  		if err != nil {
   202  			return
   203  		}
   204  		err = result.err
   205  		return
   206  	}
   207  	err = readAWSSTSPoliciesInquiryListResponse(result, reader)
   208  	if err != nil {
   209  		return
   210  	}
   211  	return
   212  }
   213  
   214  // AWSSTSPoliciesInquiryListResponse is the response for the 'list' method.
   215  type AWSSTSPoliciesInquiryListResponse struct {
   216  	status int
   217  	header http.Header
   218  	err    *errors.Error
   219  	items  *AWSSTSPolicyList
   220  	page   *int
   221  	size   *int
   222  	total  *int
   223  }
   224  
   225  // Status returns the response status code.
   226  func (r *AWSSTSPoliciesInquiryListResponse) Status() int {
   227  	if r == nil {
   228  		return 0
   229  	}
   230  	return r.status
   231  }
   232  
   233  // Header returns header of the response.
   234  func (r *AWSSTSPoliciesInquiryListResponse) Header() http.Header {
   235  	if r == nil {
   236  		return nil
   237  	}
   238  	return r.header
   239  }
   240  
   241  // Error returns the response error.
   242  func (r *AWSSTSPoliciesInquiryListResponse) Error() *errors.Error {
   243  	if r == nil {
   244  		return nil
   245  	}
   246  	return r.err
   247  }
   248  
   249  // Items returns the value of the 'items' parameter.
   250  //
   251  // Retrieved list of policies.
   252  func (r *AWSSTSPoliciesInquiryListResponse) Items() *AWSSTSPolicyList {
   253  	if r == nil {
   254  		return nil
   255  	}
   256  	return r.items
   257  }
   258  
   259  // GetItems returns the value of the 'items' parameter and
   260  // a flag indicating if the parameter has a value.
   261  //
   262  // Retrieved list of policies.
   263  func (r *AWSSTSPoliciesInquiryListResponse) GetItems() (value *AWSSTSPolicyList, ok bool) {
   264  	ok = r != nil && r.items != nil
   265  	if ok {
   266  		value = r.items
   267  	}
   268  	return
   269  }
   270  
   271  // Page returns the value of the 'page' parameter.
   272  //
   273  // Index of the requested page, where one corresponds to the first page.
   274  func (r *AWSSTSPoliciesInquiryListResponse) Page() int {
   275  	if r != nil && r.page != nil {
   276  		return *r.page
   277  	}
   278  	return 0
   279  }
   280  
   281  // GetPage returns the value of the 'page' parameter and
   282  // a flag indicating if the parameter has a value.
   283  //
   284  // Index of the requested page, where one corresponds to the first page.
   285  func (r *AWSSTSPoliciesInquiryListResponse) GetPage() (value int, ok bool) {
   286  	ok = r != nil && r.page != nil
   287  	if ok {
   288  		value = *r.page
   289  	}
   290  	return
   291  }
   292  
   293  // Size returns the value of the 'size' parameter.
   294  //
   295  // Maximum number of items that will be contained in the returned page.
   296  func (r *AWSSTSPoliciesInquiryListResponse) Size() int {
   297  	if r != nil && r.size != nil {
   298  		return *r.size
   299  	}
   300  	return 0
   301  }
   302  
   303  // GetSize returns the value of the 'size' parameter and
   304  // a flag indicating if the parameter has a value.
   305  //
   306  // Maximum number of items that will be contained in the returned page.
   307  func (r *AWSSTSPoliciesInquiryListResponse) GetSize() (value int, ok bool) {
   308  	ok = r != nil && r.size != nil
   309  	if ok {
   310  		value = *r.size
   311  	}
   312  	return
   313  }
   314  
   315  // Total returns the value of the 'total' parameter.
   316  //
   317  // Total number of items of the collection that match the search criteria,
   318  // regardless of the size of the page.
   319  func (r *AWSSTSPoliciesInquiryListResponse) Total() int {
   320  	if r != nil && r.total != nil {
   321  		return *r.total
   322  	}
   323  	return 0
   324  }
   325  
   326  // GetTotal returns the value of the 'total' parameter and
   327  // a flag indicating if the parameter has a value.
   328  //
   329  // Total number of items of the collection that match the search criteria,
   330  // regardless of the size of the page.
   331  func (r *AWSSTSPoliciesInquiryListResponse) GetTotal() (value int, ok bool) {
   332  	ok = r != nil && r.total != nil
   333  	if ok {
   334  		value = *r.total
   335  	}
   336  	return
   337  }