github.com/openshift-online/ocm-sdk-go@v0.1.473/jobqueue/v1/queue_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/jobqueue/v1
    21  
    22  import (
    23  	"bufio"
    24  	"bytes"
    25  	"context"
    26  	"io"
    27  	"net/http"
    28  	"net/url"
    29  	"path"
    30  	time "time"
    31  
    32  	"github.com/openshift-online/ocm-sdk-go/errors"
    33  	"github.com/openshift-online/ocm-sdk-go/helpers"
    34  )
    35  
    36  // QueueClient is the client of the 'queue' resource.
    37  //
    38  // Manages a specific job queue.
    39  type QueueClient struct {
    40  	transport http.RoundTripper
    41  	path      string
    42  }
    43  
    44  // NewQueueClient creates a new client for the 'queue'
    45  // resource using the given transport to send the requests and receive the
    46  // responses.
    47  func NewQueueClient(transport http.RoundTripper, path string) *QueueClient {
    48  	return &QueueClient{
    49  		transport: transport,
    50  		path:      path,
    51  	}
    52  }
    53  
    54  // Get creates a request for the 'get' method.
    55  //
    56  // Retrieves the details of a job queue by ID.
    57  func (c *QueueClient) Get() *QueueGetRequest {
    58  	return &QueueGetRequest{
    59  		transport: c.transport,
    60  		path:      c.path,
    61  	}
    62  }
    63  
    64  // Pop creates a request for the 'pop' method.
    65  //
    66  // POP new job from a job queue
    67  func (c *QueueClient) Pop() *QueuePopRequest {
    68  	return &QueuePopRequest{
    69  		transport: c.transport,
    70  		path:      path.Join(c.path, "pop"),
    71  	}
    72  }
    73  
    74  // Push creates a request for the 'push' method.
    75  //
    76  // PUSH a new job into job queue
    77  func (c *QueueClient) Push() *QueuePushRequest {
    78  	return &QueuePushRequest{
    79  		transport: c.transport,
    80  		path:      path.Join(c.path, "push"),
    81  	}
    82  }
    83  
    84  // Jobs returns the target 'jobs' resource.
    85  //
    86  // jobs' operations (success, failure)
    87  func (c *QueueClient) Jobs() *JobsClient {
    88  	return NewJobsClient(
    89  		c.transport,
    90  		path.Join(c.path, "jobs"),
    91  	)
    92  }
    93  
    94  // QueuePollRequest is the request for the Poll method.
    95  type QueuePollRequest struct {
    96  	request    *QueueGetRequest
    97  	interval   time.Duration
    98  	statuses   []int
    99  	predicates []func(interface{}) bool
   100  }
   101  
   102  // Parameter adds a query parameter to all the requests that will be used to retrieve the object.
   103  func (r *QueuePollRequest) Parameter(name string, value interface{}) *QueuePollRequest {
   104  	r.request.Parameter(name, value)
   105  	return r
   106  }
   107  
   108  // Header adds a request header to all the requests that will be used to retrieve the object.
   109  func (r *QueuePollRequest) Header(name string, value interface{}) *QueuePollRequest {
   110  	r.request.Header(name, value)
   111  	return r
   112  }
   113  
   114  // Interval sets the polling interval. This parameter is mandatory and must be greater than zero.
   115  func (r *QueuePollRequest) Interval(value time.Duration) *QueuePollRequest {
   116  	r.interval = value
   117  	return r
   118  }
   119  
   120  // Status set the expected status of the response. Multiple values can be set calling this method
   121  // multiple times. The response will be considered successful if the status is any of those values.
   122  func (r *QueuePollRequest) Status(value int) *QueuePollRequest {
   123  	r.statuses = append(r.statuses, value)
   124  	return r
   125  }
   126  
   127  // Predicate adds a predicate that the response should satisfy be considered successful. Multiple
   128  // predicates can be set calling this method multiple times. The response will be considered successful
   129  // if all the predicates are satisfied.
   130  func (r *QueuePollRequest) Predicate(value func(*QueueGetResponse) bool) *QueuePollRequest {
   131  	r.predicates = append(r.predicates, func(response interface{}) bool {
   132  		return value(response.(*QueueGetResponse))
   133  	})
   134  	return r
   135  }
   136  
   137  // StartContext starts the polling loop. Responses will be considered successful if the status is one of
   138  // the values specified with the Status method and if all the predicates specified with the Predicate
   139  // method return nil.
   140  //
   141  // The context must have a timeout or deadline, otherwise this method will immediately return an error.
   142  func (r *QueuePollRequest) StartContext(ctx context.Context) (response *QueuePollResponse, err error) {
   143  	result, err := helpers.PollContext(ctx, r.interval, r.statuses, r.predicates, r.task)
   144  	if result != nil {
   145  		response = &QueuePollResponse{
   146  			response: result.(*QueueGetResponse),
   147  		}
   148  	}
   149  	return
   150  }
   151  
   152  // task adapts the types of the request/response types so that they can be used with the generic
   153  // polling function from the helpers package.
   154  func (r *QueuePollRequest) task(ctx context.Context) (status int, result interface{}, err error) {
   155  	response, err := r.request.SendContext(ctx)
   156  	if response != nil {
   157  		status = response.Status()
   158  		result = response
   159  	}
   160  	return
   161  }
   162  
   163  // QueuePollResponse is the response for the Poll method.
   164  type QueuePollResponse struct {
   165  	response *QueueGetResponse
   166  }
   167  
   168  // Status returns the response status code.
   169  func (r *QueuePollResponse) Status() int {
   170  	if r == nil {
   171  		return 0
   172  	}
   173  	return r.response.Status()
   174  }
   175  
   176  // Header returns header of the response.
   177  func (r *QueuePollResponse) Header() http.Header {
   178  	if r == nil {
   179  		return nil
   180  	}
   181  	return r.response.Header()
   182  }
   183  
   184  // Error returns the response error.
   185  func (r *QueuePollResponse) Error() *errors.Error {
   186  	if r == nil {
   187  		return nil
   188  	}
   189  	return r.response.Error()
   190  }
   191  
   192  // Body returns the value of the 'body' parameter.
   193  func (r *QueuePollResponse) Body() *Queue {
   194  	return r.response.Body()
   195  }
   196  
   197  // GetBody returns the value of the 'body' parameter and
   198  // a flag indicating if the parameter has a value.
   199  func (r *QueuePollResponse) GetBody() (value *Queue, ok bool) {
   200  	return r.response.GetBody()
   201  }
   202  
   203  // Poll creates a request to repeatedly retrieve the object till the response has one of a given set
   204  // of states and satisfies a set of predicates.
   205  func (c *QueueClient) Poll() *QueuePollRequest {
   206  	return &QueuePollRequest{
   207  		request: c.Get(),
   208  	}
   209  }
   210  
   211  // QueueGetRequest is the request for the 'get' method.
   212  type QueueGetRequest struct {
   213  	transport http.RoundTripper
   214  	path      string
   215  	query     url.Values
   216  	header    http.Header
   217  }
   218  
   219  // Parameter adds a query parameter.
   220  func (r *QueueGetRequest) Parameter(name string, value interface{}) *QueueGetRequest {
   221  	helpers.AddValue(&r.query, name, value)
   222  	return r
   223  }
   224  
   225  // Header adds a request header.
   226  func (r *QueueGetRequest) Header(name string, value interface{}) *QueueGetRequest {
   227  	helpers.AddHeader(&r.header, name, value)
   228  	return r
   229  }
   230  
   231  // Impersonate wraps requests on behalf of another user.
   232  // Note: Services that do not support this feature may silently ignore this call.
   233  func (r *QueueGetRequest) Impersonate(user string) *QueueGetRequest {
   234  	helpers.AddImpersonationHeader(&r.header, user)
   235  	return r
   236  }
   237  
   238  // Send sends this request, waits for the response, and returns it.
   239  //
   240  // This is a potentially lengthy operation, as it requires network communication.
   241  // Consider using a context and the SendContext method.
   242  func (r *QueueGetRequest) Send() (result *QueueGetResponse, err error) {
   243  	return r.SendContext(context.Background())
   244  }
   245  
   246  // SendContext sends this request, waits for the response, and returns it.
   247  func (r *QueueGetRequest) SendContext(ctx context.Context) (result *QueueGetResponse, err error) {
   248  	query := helpers.CopyQuery(r.query)
   249  	header := helpers.CopyHeader(r.header)
   250  	uri := &url.URL{
   251  		Path:     r.path,
   252  		RawQuery: query.Encode(),
   253  	}
   254  	request := &http.Request{
   255  		Method: "GET",
   256  		URL:    uri,
   257  		Header: header,
   258  	}
   259  	if ctx != nil {
   260  		request = request.WithContext(ctx)
   261  	}
   262  	response, err := r.transport.RoundTrip(request)
   263  	if err != nil {
   264  		return
   265  	}
   266  	defer response.Body.Close()
   267  	result = &QueueGetResponse{}
   268  	result.status = response.StatusCode
   269  	result.header = response.Header
   270  	reader := bufio.NewReader(response.Body)
   271  	_, err = reader.Peek(1)
   272  	if err == io.EOF {
   273  		err = nil
   274  		return
   275  	}
   276  	if result.status >= 400 {
   277  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   278  		if err != nil {
   279  			return
   280  		}
   281  		err = result.err
   282  		return
   283  	}
   284  	err = readQueueGetResponse(result, reader)
   285  	if err != nil {
   286  		return
   287  	}
   288  	return
   289  }
   290  
   291  // QueueGetResponse is the response for the 'get' method.
   292  type QueueGetResponse struct {
   293  	status int
   294  	header http.Header
   295  	err    *errors.Error
   296  	body   *Queue
   297  }
   298  
   299  // Status returns the response status code.
   300  func (r *QueueGetResponse) Status() int {
   301  	if r == nil {
   302  		return 0
   303  	}
   304  	return r.status
   305  }
   306  
   307  // Header returns header of the response.
   308  func (r *QueueGetResponse) Header() http.Header {
   309  	if r == nil {
   310  		return nil
   311  	}
   312  	return r.header
   313  }
   314  
   315  // Error returns the response error.
   316  func (r *QueueGetResponse) Error() *errors.Error {
   317  	if r == nil {
   318  		return nil
   319  	}
   320  	return r.err
   321  }
   322  
   323  // Body returns the value of the 'body' parameter.
   324  func (r *QueueGetResponse) Body() *Queue {
   325  	if r == nil {
   326  		return nil
   327  	}
   328  	return r.body
   329  }
   330  
   331  // GetBody returns the value of the 'body' parameter and
   332  // a flag indicating if the parameter has a value.
   333  func (r *QueueGetResponse) GetBody() (value *Queue, ok bool) {
   334  	ok = r != nil && r.body != nil
   335  	if ok {
   336  		value = r.body
   337  	}
   338  	return
   339  }
   340  
   341  // QueuePopRequest is the request for the 'pop' method.
   342  type QueuePopRequest struct {
   343  	transport http.RoundTripper
   344  	path      string
   345  	query     url.Values
   346  	header    http.Header
   347  }
   348  
   349  // Parameter adds a query parameter.
   350  func (r *QueuePopRequest) Parameter(name string, value interface{}) *QueuePopRequest {
   351  	helpers.AddValue(&r.query, name, value)
   352  	return r
   353  }
   354  
   355  // Header adds a request header.
   356  func (r *QueuePopRequest) Header(name string, value interface{}) *QueuePopRequest {
   357  	helpers.AddHeader(&r.header, name, value)
   358  	return r
   359  }
   360  
   361  // Impersonate wraps requests on behalf of another user.
   362  // Note: Services that do not support this feature may silently ignore this call.
   363  func (r *QueuePopRequest) Impersonate(user string) *QueuePopRequest {
   364  	helpers.AddImpersonationHeader(&r.header, user)
   365  	return r
   366  }
   367  
   368  // Send sends this request, waits for the response, and returns it.
   369  //
   370  // This is a potentially lengthy operation, as it requires network communication.
   371  // Consider using a context and the SendContext method.
   372  func (r *QueuePopRequest) Send() (result *QueuePopResponse, err error) {
   373  	return r.SendContext(context.Background())
   374  }
   375  
   376  // SendContext sends this request, waits for the response, and returns it.
   377  func (r *QueuePopRequest) SendContext(ctx context.Context) (result *QueuePopResponse, err error) {
   378  	query := helpers.CopyQuery(r.query)
   379  	header := helpers.CopyHeader(r.header)
   380  	uri := &url.URL{
   381  		Path:     r.path,
   382  		RawQuery: query.Encode(),
   383  	}
   384  	request := &http.Request{
   385  		Method: "POST",
   386  		URL:    uri,
   387  		Header: header,
   388  	}
   389  	if ctx != nil {
   390  		request = request.WithContext(ctx)
   391  	}
   392  	response, err := r.transport.RoundTrip(request)
   393  	if err != nil {
   394  		return
   395  	}
   396  	defer response.Body.Close()
   397  	result = &QueuePopResponse{}
   398  	result.status = response.StatusCode
   399  	result.header = response.Header
   400  	reader := bufio.NewReader(response.Body)
   401  	_, err = reader.Peek(1)
   402  	if err == io.EOF {
   403  		err = nil
   404  		return
   405  	}
   406  	if result.status >= 400 {
   407  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   408  		if err != nil {
   409  			return
   410  		}
   411  		err = result.err
   412  		return
   413  	}
   414  	err = readQueuePopResponse(result, reader)
   415  	if err != nil {
   416  		return
   417  	}
   418  	return
   419  }
   420  
   421  // QueuePopResponse is the response for the 'pop' method.
   422  type QueuePopResponse struct {
   423  	status      int
   424  	header      http.Header
   425  	err         *errors.Error
   426  	href        *string
   427  	id          *string
   428  	abandonedAt *time.Time
   429  	arguments   *string
   430  	attempts    *int
   431  	createdAt   *time.Time
   432  	kind        *string
   433  	receiptId   *string
   434  	updatedAt   *time.Time
   435  }
   436  
   437  // Status returns the response status code.
   438  func (r *QueuePopResponse) Status() int {
   439  	if r == nil {
   440  		return 0
   441  	}
   442  	return r.status
   443  }
   444  
   445  // Header returns header of the response.
   446  func (r *QueuePopResponse) Header() http.Header {
   447  	if r == nil {
   448  		return nil
   449  	}
   450  	return r.header
   451  }
   452  
   453  // Error returns the response error.
   454  func (r *QueuePopResponse) Error() *errors.Error {
   455  	if r == nil {
   456  		return nil
   457  	}
   458  	return r.err
   459  }
   460  
   461  // HREF returns the value of the 'HREF' parameter.
   462  func (r *QueuePopResponse) HREF() string {
   463  	if r != nil && r.href != nil {
   464  		return *r.href
   465  	}
   466  	return ""
   467  }
   468  
   469  // GetHREF returns the value of the 'HREF' parameter and
   470  // a flag indicating if the parameter has a value.
   471  func (r *QueuePopResponse) GetHREF() (value string, ok bool) {
   472  	ok = r != nil && r.href != nil
   473  	if ok {
   474  		value = *r.href
   475  	}
   476  	return
   477  }
   478  
   479  // ID returns the value of the 'ID' parameter.
   480  func (r *QueuePopResponse) ID() string {
   481  	if r != nil && r.id != nil {
   482  		return *r.id
   483  	}
   484  	return ""
   485  }
   486  
   487  // GetID returns the value of the 'ID' parameter and
   488  // a flag indicating if the parameter has a value.
   489  func (r *QueuePopResponse) GetID() (value string, ok bool) {
   490  	ok = r != nil && r.id != nil
   491  	if ok {
   492  		value = *r.id
   493  	}
   494  	return
   495  }
   496  
   497  // AbandonedAt returns the value of the 'abandoned_at' parameter.
   498  func (r *QueuePopResponse) AbandonedAt() time.Time {
   499  	if r != nil && r.abandonedAt != nil {
   500  		return *r.abandonedAt
   501  	}
   502  	return time.Time{}
   503  }
   504  
   505  // GetAbandonedAt returns the value of the 'abandoned_at' parameter and
   506  // a flag indicating if the parameter has a value.
   507  func (r *QueuePopResponse) GetAbandonedAt() (value time.Time, ok bool) {
   508  	ok = r != nil && r.abandonedAt != nil
   509  	if ok {
   510  		value = *r.abandonedAt
   511  	}
   512  	return
   513  }
   514  
   515  // Arguments returns the value of the 'arguments' parameter.
   516  func (r *QueuePopResponse) Arguments() string {
   517  	if r != nil && r.arguments != nil {
   518  		return *r.arguments
   519  	}
   520  	return ""
   521  }
   522  
   523  // GetArguments returns the value of the 'arguments' parameter and
   524  // a flag indicating if the parameter has a value.
   525  func (r *QueuePopResponse) GetArguments() (value string, ok bool) {
   526  	ok = r != nil && r.arguments != nil
   527  	if ok {
   528  		value = *r.arguments
   529  	}
   530  	return
   531  }
   532  
   533  // Attempts returns the value of the 'attempts' parameter.
   534  func (r *QueuePopResponse) Attempts() int {
   535  	if r != nil && r.attempts != nil {
   536  		return *r.attempts
   537  	}
   538  	return 0
   539  }
   540  
   541  // GetAttempts returns the value of the 'attempts' parameter and
   542  // a flag indicating if the parameter has a value.
   543  func (r *QueuePopResponse) GetAttempts() (value int, ok bool) {
   544  	ok = r != nil && r.attempts != nil
   545  	if ok {
   546  		value = *r.attempts
   547  	}
   548  	return
   549  }
   550  
   551  // CreatedAt returns the value of the 'created_at' parameter.
   552  func (r *QueuePopResponse) CreatedAt() time.Time {
   553  	if r != nil && r.createdAt != nil {
   554  		return *r.createdAt
   555  	}
   556  	return time.Time{}
   557  }
   558  
   559  // GetCreatedAt returns the value of the 'created_at' parameter and
   560  // a flag indicating if the parameter has a value.
   561  func (r *QueuePopResponse) GetCreatedAt() (value time.Time, ok bool) {
   562  	ok = r != nil && r.createdAt != nil
   563  	if ok {
   564  		value = *r.createdAt
   565  	}
   566  	return
   567  }
   568  
   569  // Kind returns the value of the 'kind' parameter.
   570  func (r *QueuePopResponse) Kind() string {
   571  	if r != nil && r.kind != nil {
   572  		return *r.kind
   573  	}
   574  	return ""
   575  }
   576  
   577  // GetKind returns the value of the 'kind' parameter and
   578  // a flag indicating if the parameter has a value.
   579  func (r *QueuePopResponse) GetKind() (value string, ok bool) {
   580  	ok = r != nil && r.kind != nil
   581  	if ok {
   582  		value = *r.kind
   583  	}
   584  	return
   585  }
   586  
   587  // ReceiptId returns the value of the 'receipt_id' parameter.
   588  func (r *QueuePopResponse) ReceiptId() string {
   589  	if r != nil && r.receiptId != nil {
   590  		return *r.receiptId
   591  	}
   592  	return ""
   593  }
   594  
   595  // GetReceiptId returns the value of the 'receipt_id' parameter and
   596  // a flag indicating if the parameter has a value.
   597  func (r *QueuePopResponse) GetReceiptId() (value string, ok bool) {
   598  	ok = r != nil && r.receiptId != nil
   599  	if ok {
   600  		value = *r.receiptId
   601  	}
   602  	return
   603  }
   604  
   605  // UpdatedAt returns the value of the 'updated_at' parameter.
   606  func (r *QueuePopResponse) UpdatedAt() time.Time {
   607  	if r != nil && r.updatedAt != nil {
   608  		return *r.updatedAt
   609  	}
   610  	return time.Time{}
   611  }
   612  
   613  // GetUpdatedAt returns the value of the 'updated_at' parameter and
   614  // a flag indicating if the parameter has a value.
   615  func (r *QueuePopResponse) GetUpdatedAt() (value time.Time, ok bool) {
   616  	ok = r != nil && r.updatedAt != nil
   617  	if ok {
   618  		value = *r.updatedAt
   619  	}
   620  	return
   621  }
   622  
   623  // QueuePushRequest is the request for the 'push' method.
   624  type QueuePushRequest struct {
   625  	transport   http.RoundTripper
   626  	path        string
   627  	query       url.Values
   628  	header      http.Header
   629  	abandonedAt *time.Time
   630  	arguments   *string
   631  	attempts    *int
   632  	createdAt   *time.Time
   633  }
   634  
   635  // Parameter adds a query parameter.
   636  func (r *QueuePushRequest) Parameter(name string, value interface{}) *QueuePushRequest {
   637  	helpers.AddValue(&r.query, name, value)
   638  	return r
   639  }
   640  
   641  // Header adds a request header.
   642  func (r *QueuePushRequest) Header(name string, value interface{}) *QueuePushRequest {
   643  	helpers.AddHeader(&r.header, name, value)
   644  	return r
   645  }
   646  
   647  // Impersonate wraps requests on behalf of another user.
   648  // Note: Services that do not support this feature may silently ignore this call.
   649  func (r *QueuePushRequest) Impersonate(user string) *QueuePushRequest {
   650  	helpers.AddImpersonationHeader(&r.header, user)
   651  	return r
   652  }
   653  
   654  // AbandonedAt sets the value of the 'abandoned_at' parameter.
   655  func (r *QueuePushRequest) AbandonedAt(value time.Time) *QueuePushRequest {
   656  	r.abandonedAt = &value
   657  	return r
   658  }
   659  
   660  // Arguments sets the value of the 'arguments' parameter.
   661  func (r *QueuePushRequest) Arguments(value string) *QueuePushRequest {
   662  	r.arguments = &value
   663  	return r
   664  }
   665  
   666  // Attempts sets the value of the 'attempts' parameter.
   667  func (r *QueuePushRequest) Attempts(value int) *QueuePushRequest {
   668  	r.attempts = &value
   669  	return r
   670  }
   671  
   672  // CreatedAt sets the value of the 'created_at' parameter.
   673  func (r *QueuePushRequest) CreatedAt(value time.Time) *QueuePushRequest {
   674  	r.createdAt = &value
   675  	return r
   676  }
   677  
   678  // Send sends this request, waits for the response, and returns it.
   679  //
   680  // This is a potentially lengthy operation, as it requires network communication.
   681  // Consider using a context and the SendContext method.
   682  func (r *QueuePushRequest) Send() (result *QueuePushResponse, err error) {
   683  	return r.SendContext(context.Background())
   684  }
   685  
   686  // SendContext sends this request, waits for the response, and returns it.
   687  func (r *QueuePushRequest) SendContext(ctx context.Context) (result *QueuePushResponse, err error) {
   688  	query := helpers.CopyQuery(r.query)
   689  	header := helpers.CopyHeader(r.header)
   690  	buffer := &bytes.Buffer{}
   691  	err = writeQueuePushRequest(r, buffer)
   692  	if err != nil {
   693  		return
   694  	}
   695  	uri := &url.URL{
   696  		Path:     r.path,
   697  		RawQuery: query.Encode(),
   698  	}
   699  	request := &http.Request{
   700  		Method: "POST",
   701  		URL:    uri,
   702  		Header: header,
   703  		Body:   io.NopCloser(buffer),
   704  	}
   705  	if ctx != nil {
   706  		request = request.WithContext(ctx)
   707  	}
   708  	response, err := r.transport.RoundTrip(request)
   709  	if err != nil {
   710  		return
   711  	}
   712  	defer response.Body.Close()
   713  	result = &QueuePushResponse{}
   714  	result.status = response.StatusCode
   715  	result.header = response.Header
   716  	reader := bufio.NewReader(response.Body)
   717  	_, err = reader.Peek(1)
   718  	if err == io.EOF {
   719  		err = nil
   720  		return
   721  	}
   722  	if result.status >= 400 {
   723  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   724  		if err != nil {
   725  			return
   726  		}
   727  		err = result.err
   728  		return
   729  	}
   730  	err = readQueuePushResponse(result, reader)
   731  	if err != nil {
   732  		return
   733  	}
   734  	return
   735  }
   736  
   737  // QueuePushResponse is the response for the 'push' method.
   738  type QueuePushResponse struct {
   739  	status      int
   740  	header      http.Header
   741  	err         *errors.Error
   742  	href        *string
   743  	id          *string
   744  	abandonedAt *time.Time
   745  	arguments   *string
   746  	attempts    *int
   747  	createdAt   *time.Time
   748  	kind        *string
   749  	receiptId   *string
   750  	updatedAt   *time.Time
   751  }
   752  
   753  // Status returns the response status code.
   754  func (r *QueuePushResponse) Status() int {
   755  	if r == nil {
   756  		return 0
   757  	}
   758  	return r.status
   759  }
   760  
   761  // Header returns header of the response.
   762  func (r *QueuePushResponse) Header() http.Header {
   763  	if r == nil {
   764  		return nil
   765  	}
   766  	return r.header
   767  }
   768  
   769  // Error returns the response error.
   770  func (r *QueuePushResponse) Error() *errors.Error {
   771  	if r == nil {
   772  		return nil
   773  	}
   774  	return r.err
   775  }
   776  
   777  // HREF returns the value of the 'HREF' parameter.
   778  func (r *QueuePushResponse) HREF() string {
   779  	if r != nil && r.href != nil {
   780  		return *r.href
   781  	}
   782  	return ""
   783  }
   784  
   785  // GetHREF returns the value of the 'HREF' parameter and
   786  // a flag indicating if the parameter has a value.
   787  func (r *QueuePushResponse) GetHREF() (value string, ok bool) {
   788  	ok = r != nil && r.href != nil
   789  	if ok {
   790  		value = *r.href
   791  	}
   792  	return
   793  }
   794  
   795  // ID returns the value of the 'ID' parameter.
   796  func (r *QueuePushResponse) ID() string {
   797  	if r != nil && r.id != nil {
   798  		return *r.id
   799  	}
   800  	return ""
   801  }
   802  
   803  // GetID returns the value of the 'ID' parameter and
   804  // a flag indicating if the parameter has a value.
   805  func (r *QueuePushResponse) GetID() (value string, ok bool) {
   806  	ok = r != nil && r.id != nil
   807  	if ok {
   808  		value = *r.id
   809  	}
   810  	return
   811  }
   812  
   813  // AbandonedAt returns the value of the 'abandoned_at' parameter.
   814  func (r *QueuePushResponse) AbandonedAt() time.Time {
   815  	if r != nil && r.abandonedAt != nil {
   816  		return *r.abandonedAt
   817  	}
   818  	return time.Time{}
   819  }
   820  
   821  // GetAbandonedAt returns the value of the 'abandoned_at' parameter and
   822  // a flag indicating if the parameter has a value.
   823  func (r *QueuePushResponse) GetAbandonedAt() (value time.Time, ok bool) {
   824  	ok = r != nil && r.abandonedAt != nil
   825  	if ok {
   826  		value = *r.abandonedAt
   827  	}
   828  	return
   829  }
   830  
   831  // Arguments returns the value of the 'arguments' parameter.
   832  func (r *QueuePushResponse) Arguments() string {
   833  	if r != nil && r.arguments != nil {
   834  		return *r.arguments
   835  	}
   836  	return ""
   837  }
   838  
   839  // GetArguments returns the value of the 'arguments' parameter and
   840  // a flag indicating if the parameter has a value.
   841  func (r *QueuePushResponse) GetArguments() (value string, ok bool) {
   842  	ok = r != nil && r.arguments != nil
   843  	if ok {
   844  		value = *r.arguments
   845  	}
   846  	return
   847  }
   848  
   849  // Attempts returns the value of the 'attempts' parameter.
   850  func (r *QueuePushResponse) Attempts() int {
   851  	if r != nil && r.attempts != nil {
   852  		return *r.attempts
   853  	}
   854  	return 0
   855  }
   856  
   857  // GetAttempts returns the value of the 'attempts' parameter and
   858  // a flag indicating if the parameter has a value.
   859  func (r *QueuePushResponse) GetAttempts() (value int, ok bool) {
   860  	ok = r != nil && r.attempts != nil
   861  	if ok {
   862  		value = *r.attempts
   863  	}
   864  	return
   865  }
   866  
   867  // CreatedAt returns the value of the 'created_at' parameter.
   868  func (r *QueuePushResponse) CreatedAt() time.Time {
   869  	if r != nil && r.createdAt != nil {
   870  		return *r.createdAt
   871  	}
   872  	return time.Time{}
   873  }
   874  
   875  // GetCreatedAt returns the value of the 'created_at' parameter and
   876  // a flag indicating if the parameter has a value.
   877  func (r *QueuePushResponse) GetCreatedAt() (value time.Time, ok bool) {
   878  	ok = r != nil && r.createdAt != nil
   879  	if ok {
   880  		value = *r.createdAt
   881  	}
   882  	return
   883  }
   884  
   885  // Kind returns the value of the 'kind' parameter.
   886  func (r *QueuePushResponse) Kind() string {
   887  	if r != nil && r.kind != nil {
   888  		return *r.kind
   889  	}
   890  	return ""
   891  }
   892  
   893  // GetKind returns the value of the 'kind' parameter and
   894  // a flag indicating if the parameter has a value.
   895  func (r *QueuePushResponse) GetKind() (value string, ok bool) {
   896  	ok = r != nil && r.kind != nil
   897  	if ok {
   898  		value = *r.kind
   899  	}
   900  	return
   901  }
   902  
   903  // ReceiptId returns the value of the 'receipt_id' parameter.
   904  func (r *QueuePushResponse) ReceiptId() string {
   905  	if r != nil && r.receiptId != nil {
   906  		return *r.receiptId
   907  	}
   908  	return ""
   909  }
   910  
   911  // GetReceiptId returns the value of the 'receipt_id' parameter and
   912  // a flag indicating if the parameter has a value.
   913  func (r *QueuePushResponse) GetReceiptId() (value string, ok bool) {
   914  	ok = r != nil && r.receiptId != nil
   915  	if ok {
   916  		value = *r.receiptId
   917  	}
   918  	return
   919  }
   920  
   921  // UpdatedAt returns the value of the 'updated_at' parameter.
   922  func (r *QueuePushResponse) UpdatedAt() time.Time {
   923  	if r != nil && r.updatedAt != nil {
   924  		return *r.updatedAt
   925  	}
   926  	return time.Time{}
   927  }
   928  
   929  // GetUpdatedAt returns the value of the 'updated_at' parameter and
   930  // a flag indicating if the parameter has a value.
   931  func (r *QueuePushResponse) GetUpdatedAt() (value time.Time, ok bool) {
   932  	ok = r != nil && r.updatedAt != nil
   933  	if ok {
   934  		value = *r.updatedAt
   935  	}
   936  	return
   937  }