github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionExact.go (about)

     1  // Code generated by msgraph.go/gen DO NOT EDIT.
     2  
     3  package msgraph
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  	"io/ioutil"
     9  	"net/http"
    10  
    11  	"github.com/yaegashi/msgraph.go/jsonx"
    12  )
    13  
    14  // ExactMatchDataStoreLookupRequestParameter undocumented
    15  type ExactMatchDataStoreLookupRequestParameter struct {
    16  	// Key undocumented
    17  	Key *string `json:"key,omitempty"`
    18  	// Values undocumented
    19  	Values []string `json:"values,omitempty"`
    20  	// ResultColumnNames undocumented
    21  	ResultColumnNames []string `json:"resultColumnNames,omitempty"`
    22  }
    23  
    24  // ExactMatchSessionCancelRequestParameter undocumented
    25  type ExactMatchSessionCancelRequestParameter struct {
    26  }
    27  
    28  // ExactMatchSessionCommitRequestParameter undocumented
    29  type ExactMatchSessionCommitRequestParameter struct {
    30  }
    31  
    32  // ExactMatchSessionRenewRequestParameter undocumented
    33  type ExactMatchSessionRenewRequestParameter struct {
    34  }
    35  
    36  // Sessions returns request builder for ExactMatchSession collection
    37  func (b *ExactMatchDataStoreRequestBuilder) Sessions() *ExactMatchDataStoreSessionsCollectionRequestBuilder {
    38  	bb := &ExactMatchDataStoreSessionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    39  	bb.baseURL += "/sessions"
    40  	return bb
    41  }
    42  
    43  // ExactMatchDataStoreSessionsCollectionRequestBuilder is request builder for ExactMatchSession collection
    44  type ExactMatchDataStoreSessionsCollectionRequestBuilder struct{ BaseRequestBuilder }
    45  
    46  // Request returns request for ExactMatchSession collection
    47  func (b *ExactMatchDataStoreSessionsCollectionRequestBuilder) Request() *ExactMatchDataStoreSessionsCollectionRequest {
    48  	return &ExactMatchDataStoreSessionsCollectionRequest{
    49  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
    50  	}
    51  }
    52  
    53  // ID returns request builder for ExactMatchSession item
    54  func (b *ExactMatchDataStoreSessionsCollectionRequestBuilder) ID(id string) *ExactMatchSessionRequestBuilder {
    55  	bb := &ExactMatchSessionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    56  	bb.baseURL += "/" + id
    57  	return bb
    58  }
    59  
    60  // ExactMatchDataStoreSessionsCollectionRequest is request for ExactMatchSession collection
    61  type ExactMatchDataStoreSessionsCollectionRequest struct{ BaseRequest }
    62  
    63  // Paging perfoms paging operation for ExactMatchSession collection
    64  func (r *ExactMatchDataStoreSessionsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]ExactMatchSession, error) {
    65  	req, err := r.NewJSONRequest(method, path, obj)
    66  	if err != nil {
    67  		return nil, err
    68  	}
    69  	if ctx != nil {
    70  		req = req.WithContext(ctx)
    71  	}
    72  	res, err := r.client.Do(req)
    73  	if err != nil {
    74  		return nil, err
    75  	}
    76  	var values []ExactMatchSession
    77  	for {
    78  		if res.StatusCode != http.StatusOK {
    79  			b, _ := ioutil.ReadAll(res.Body)
    80  			res.Body.Close()
    81  			errRes := &ErrorResponse{Response: res}
    82  			err := jsonx.Unmarshal(b, errRes)
    83  			if err != nil {
    84  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
    85  			}
    86  			return nil, errRes
    87  		}
    88  		var (
    89  			paging Paging
    90  			value  []ExactMatchSession
    91  		)
    92  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
    93  		res.Body.Close()
    94  		if err != nil {
    95  			return nil, err
    96  		}
    97  		err = jsonx.Unmarshal(paging.Value, &value)
    98  		if err != nil {
    99  			return nil, err
   100  		}
   101  		values = append(values, value...)
   102  		if n >= 0 {
   103  			n--
   104  		}
   105  		if n == 0 || len(paging.NextLink) == 0 {
   106  			return values, nil
   107  		}
   108  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   109  		if ctx != nil {
   110  			req = req.WithContext(ctx)
   111  		}
   112  		res, err = r.client.Do(req)
   113  		if err != nil {
   114  			return nil, err
   115  		}
   116  	}
   117  }
   118  
   119  // GetN performs GET request for ExactMatchSession collection, max N pages
   120  func (r *ExactMatchDataStoreSessionsCollectionRequest) GetN(ctx context.Context, n int) ([]ExactMatchSession, error) {
   121  	var query string
   122  	if r.query != nil {
   123  		query = "?" + r.query.Encode()
   124  	}
   125  	return r.Paging(ctx, "GET", query, nil, n)
   126  }
   127  
   128  // Get performs GET request for ExactMatchSession collection
   129  func (r *ExactMatchDataStoreSessionsCollectionRequest) Get(ctx context.Context) ([]ExactMatchSession, error) {
   130  	return r.GetN(ctx, 0)
   131  }
   132  
   133  // Add performs POST request for ExactMatchSession collection
   134  func (r *ExactMatchDataStoreSessionsCollectionRequest) Add(ctx context.Context, reqObj *ExactMatchSession) (resObj *ExactMatchSession, err error) {
   135  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   136  	return
   137  }
   138  
   139  // MatchingRows returns request builder for LookupResultRow collection
   140  func (b *ExactMatchLookupJobRequestBuilder) MatchingRows() *ExactMatchLookupJobMatchingRowsCollectionRequestBuilder {
   141  	bb := &ExactMatchLookupJobMatchingRowsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   142  	bb.baseURL += "/matchingRows"
   143  	return bb
   144  }
   145  
   146  // ExactMatchLookupJobMatchingRowsCollectionRequestBuilder is request builder for LookupResultRow collection
   147  type ExactMatchLookupJobMatchingRowsCollectionRequestBuilder struct{ BaseRequestBuilder }
   148  
   149  // Request returns request for LookupResultRow collection
   150  func (b *ExactMatchLookupJobMatchingRowsCollectionRequestBuilder) Request() *ExactMatchLookupJobMatchingRowsCollectionRequest {
   151  	return &ExactMatchLookupJobMatchingRowsCollectionRequest{
   152  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   153  	}
   154  }
   155  
   156  // ID returns request builder for LookupResultRow item
   157  func (b *ExactMatchLookupJobMatchingRowsCollectionRequestBuilder) ID(id string) *LookupResultRowRequestBuilder {
   158  	bb := &LookupResultRowRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   159  	bb.baseURL += "/" + id
   160  	return bb
   161  }
   162  
   163  // ExactMatchLookupJobMatchingRowsCollectionRequest is request for LookupResultRow collection
   164  type ExactMatchLookupJobMatchingRowsCollectionRequest struct{ BaseRequest }
   165  
   166  // Paging perfoms paging operation for LookupResultRow collection
   167  func (r *ExactMatchLookupJobMatchingRowsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]LookupResultRow, error) {
   168  	req, err := r.NewJSONRequest(method, path, obj)
   169  	if err != nil {
   170  		return nil, err
   171  	}
   172  	if ctx != nil {
   173  		req = req.WithContext(ctx)
   174  	}
   175  	res, err := r.client.Do(req)
   176  	if err != nil {
   177  		return nil, err
   178  	}
   179  	var values []LookupResultRow
   180  	for {
   181  		if res.StatusCode != http.StatusOK {
   182  			b, _ := ioutil.ReadAll(res.Body)
   183  			res.Body.Close()
   184  			errRes := &ErrorResponse{Response: res}
   185  			err := jsonx.Unmarshal(b, errRes)
   186  			if err != nil {
   187  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   188  			}
   189  			return nil, errRes
   190  		}
   191  		var (
   192  			paging Paging
   193  			value  []LookupResultRow
   194  		)
   195  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   196  		res.Body.Close()
   197  		if err != nil {
   198  			return nil, err
   199  		}
   200  		err = jsonx.Unmarshal(paging.Value, &value)
   201  		if err != nil {
   202  			return nil, err
   203  		}
   204  		values = append(values, value...)
   205  		if n >= 0 {
   206  			n--
   207  		}
   208  		if n == 0 || len(paging.NextLink) == 0 {
   209  			return values, nil
   210  		}
   211  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   212  		if ctx != nil {
   213  			req = req.WithContext(ctx)
   214  		}
   215  		res, err = r.client.Do(req)
   216  		if err != nil {
   217  			return nil, err
   218  		}
   219  	}
   220  }
   221  
   222  // GetN performs GET request for LookupResultRow collection, max N pages
   223  func (r *ExactMatchLookupJobMatchingRowsCollectionRequest) GetN(ctx context.Context, n int) ([]LookupResultRow, error) {
   224  	var query string
   225  	if r.query != nil {
   226  		query = "?" + r.query.Encode()
   227  	}
   228  	return r.Paging(ctx, "GET", query, nil, n)
   229  }
   230  
   231  // Get performs GET request for LookupResultRow collection
   232  func (r *ExactMatchLookupJobMatchingRowsCollectionRequest) Get(ctx context.Context) ([]LookupResultRow, error) {
   233  	return r.GetN(ctx, 0)
   234  }
   235  
   236  // Add performs POST request for LookupResultRow collection
   237  func (r *ExactMatchLookupJobMatchingRowsCollectionRequest) Add(ctx context.Context, reqObj *LookupResultRow) (resObj *LookupResultRow, err error) {
   238  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   239  	return
   240  }
   241  
   242  // UploadAgent is navigation property
   243  func (b *ExactMatchSessionRequestBuilder) UploadAgent() *ExactMatchUploadAgentRequestBuilder {
   244  	bb := &ExactMatchUploadAgentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   245  	bb.baseURL += "/uploadAgent"
   246  	return bb
   247  }