github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionCloud.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  // CloudCommunicationsGetPresencesByUserIDRequestParameter undocumented
    15  type CloudCommunicationsGetPresencesByUserIDRequestParameter struct {
    16  	// IDs undocumented
    17  	IDs []string `json:"ids,omitempty"`
    18  }
    19  
    20  // Calls returns request builder for Call collection
    21  func (b *CloudCommunicationsRequestBuilder) Calls() *CloudCommunicationsCallsCollectionRequestBuilder {
    22  	bb := &CloudCommunicationsCallsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    23  	bb.baseURL += "/calls"
    24  	return bb
    25  }
    26  
    27  // CloudCommunicationsCallsCollectionRequestBuilder is request builder for Call collection
    28  type CloudCommunicationsCallsCollectionRequestBuilder struct{ BaseRequestBuilder }
    29  
    30  // Request returns request for Call collection
    31  func (b *CloudCommunicationsCallsCollectionRequestBuilder) Request() *CloudCommunicationsCallsCollectionRequest {
    32  	return &CloudCommunicationsCallsCollectionRequest{
    33  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
    34  	}
    35  }
    36  
    37  // ID returns request builder for Call item
    38  func (b *CloudCommunicationsCallsCollectionRequestBuilder) ID(id string) *CallRequestBuilder {
    39  	bb := &CallRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    40  	bb.baseURL += "/" + id
    41  	return bb
    42  }
    43  
    44  // CloudCommunicationsCallsCollectionRequest is request for Call collection
    45  type CloudCommunicationsCallsCollectionRequest struct{ BaseRequest }
    46  
    47  // Paging perfoms paging operation for Call collection
    48  func (r *CloudCommunicationsCallsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]Call, error) {
    49  	req, err := r.NewJSONRequest(method, path, obj)
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  	if ctx != nil {
    54  		req = req.WithContext(ctx)
    55  	}
    56  	res, err := r.client.Do(req)
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  	var values []Call
    61  	for {
    62  		if res.StatusCode != http.StatusOK {
    63  			b, _ := ioutil.ReadAll(res.Body)
    64  			res.Body.Close()
    65  			errRes := &ErrorResponse{Response: res}
    66  			err := jsonx.Unmarshal(b, errRes)
    67  			if err != nil {
    68  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
    69  			}
    70  			return nil, errRes
    71  		}
    72  		var (
    73  			paging Paging
    74  			value  []Call
    75  		)
    76  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
    77  		res.Body.Close()
    78  		if err != nil {
    79  			return nil, err
    80  		}
    81  		err = jsonx.Unmarshal(paging.Value, &value)
    82  		if err != nil {
    83  			return nil, err
    84  		}
    85  		values = append(values, value...)
    86  		if n >= 0 {
    87  			n--
    88  		}
    89  		if n == 0 || len(paging.NextLink) == 0 {
    90  			return values, nil
    91  		}
    92  		req, err = http.NewRequest("GET", paging.NextLink, nil)
    93  		if ctx != nil {
    94  			req = req.WithContext(ctx)
    95  		}
    96  		res, err = r.client.Do(req)
    97  		if err != nil {
    98  			return nil, err
    99  		}
   100  	}
   101  }
   102  
   103  // GetN performs GET request for Call collection, max N pages
   104  func (r *CloudCommunicationsCallsCollectionRequest) GetN(ctx context.Context, n int) ([]Call, error) {
   105  	var query string
   106  	if r.query != nil {
   107  		query = "?" + r.query.Encode()
   108  	}
   109  	return r.Paging(ctx, "GET", query, nil, n)
   110  }
   111  
   112  // Get performs GET request for Call collection
   113  func (r *CloudCommunicationsCallsCollectionRequest) Get(ctx context.Context) ([]Call, error) {
   114  	return r.GetN(ctx, 0)
   115  }
   116  
   117  // Add performs POST request for Call collection
   118  func (r *CloudCommunicationsCallsCollectionRequest) Add(ctx context.Context, reqObj *Call) (resObj *Call, err error) {
   119  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   120  	return
   121  }
   122  
   123  // OnlineMeetings returns request builder for OnlineMeeting collection
   124  func (b *CloudCommunicationsRequestBuilder) OnlineMeetings() *CloudCommunicationsOnlineMeetingsCollectionRequestBuilder {
   125  	bb := &CloudCommunicationsOnlineMeetingsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   126  	bb.baseURL += "/onlineMeetings"
   127  	return bb
   128  }
   129  
   130  // CloudCommunicationsOnlineMeetingsCollectionRequestBuilder is request builder for OnlineMeeting collection
   131  type CloudCommunicationsOnlineMeetingsCollectionRequestBuilder struct{ BaseRequestBuilder }
   132  
   133  // Request returns request for OnlineMeeting collection
   134  func (b *CloudCommunicationsOnlineMeetingsCollectionRequestBuilder) Request() *CloudCommunicationsOnlineMeetingsCollectionRequest {
   135  	return &CloudCommunicationsOnlineMeetingsCollectionRequest{
   136  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   137  	}
   138  }
   139  
   140  // ID returns request builder for OnlineMeeting item
   141  func (b *CloudCommunicationsOnlineMeetingsCollectionRequestBuilder) ID(id string) *OnlineMeetingRequestBuilder {
   142  	bb := &OnlineMeetingRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   143  	bb.baseURL += "/" + id
   144  	return bb
   145  }
   146  
   147  // CloudCommunicationsOnlineMeetingsCollectionRequest is request for OnlineMeeting collection
   148  type CloudCommunicationsOnlineMeetingsCollectionRequest struct{ BaseRequest }
   149  
   150  // Paging perfoms paging operation for OnlineMeeting collection
   151  func (r *CloudCommunicationsOnlineMeetingsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]OnlineMeeting, error) {
   152  	req, err := r.NewJSONRequest(method, path, obj)
   153  	if err != nil {
   154  		return nil, err
   155  	}
   156  	if ctx != nil {
   157  		req = req.WithContext(ctx)
   158  	}
   159  	res, err := r.client.Do(req)
   160  	if err != nil {
   161  		return nil, err
   162  	}
   163  	var values []OnlineMeeting
   164  	for {
   165  		if res.StatusCode != http.StatusOK {
   166  			b, _ := ioutil.ReadAll(res.Body)
   167  			res.Body.Close()
   168  			errRes := &ErrorResponse{Response: res}
   169  			err := jsonx.Unmarshal(b, errRes)
   170  			if err != nil {
   171  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   172  			}
   173  			return nil, errRes
   174  		}
   175  		var (
   176  			paging Paging
   177  			value  []OnlineMeeting
   178  		)
   179  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   180  		res.Body.Close()
   181  		if err != nil {
   182  			return nil, err
   183  		}
   184  		err = jsonx.Unmarshal(paging.Value, &value)
   185  		if err != nil {
   186  			return nil, err
   187  		}
   188  		values = append(values, value...)
   189  		if n >= 0 {
   190  			n--
   191  		}
   192  		if n == 0 || len(paging.NextLink) == 0 {
   193  			return values, nil
   194  		}
   195  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   196  		if ctx != nil {
   197  			req = req.WithContext(ctx)
   198  		}
   199  		res, err = r.client.Do(req)
   200  		if err != nil {
   201  			return nil, err
   202  		}
   203  	}
   204  }
   205  
   206  // GetN performs GET request for OnlineMeeting collection, max N pages
   207  func (r *CloudCommunicationsOnlineMeetingsCollectionRequest) GetN(ctx context.Context, n int) ([]OnlineMeeting, error) {
   208  	var query string
   209  	if r.query != nil {
   210  		query = "?" + r.query.Encode()
   211  	}
   212  	return r.Paging(ctx, "GET", query, nil, n)
   213  }
   214  
   215  // Get performs GET request for OnlineMeeting collection
   216  func (r *CloudCommunicationsOnlineMeetingsCollectionRequest) Get(ctx context.Context) ([]OnlineMeeting, error) {
   217  	return r.GetN(ctx, 0)
   218  }
   219  
   220  // Add performs POST request for OnlineMeeting collection
   221  func (r *CloudCommunicationsOnlineMeetingsCollectionRequest) Add(ctx context.Context, reqObj *OnlineMeeting) (resObj *OnlineMeeting, err error) {
   222  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   223  	return
   224  }