github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionOffice.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  // OfficeClientConfigurationCollectionUpdatePrioritiesRequestParameter undocumented
    15  type OfficeClientConfigurationCollectionUpdatePrioritiesRequestParameter struct {
    16  	// OfficeConfigurationPolicyIDs undocumented
    17  	OfficeConfigurationPolicyIDs []string `json:"officeConfigurationPolicyIds,omitempty"`
    18  	// OfficeConfigurationPriorities undocumented
    19  	OfficeConfigurationPriorities []int `json:"officeConfigurationPriorities,omitempty"`
    20  }
    21  
    22  // OfficeClientConfigurationAssignRequestParameter undocumented
    23  type OfficeClientConfigurationAssignRequestParameter struct {
    24  	// OfficeConfigurationAssignments undocumented
    25  	OfficeConfigurationAssignments []OfficeClientConfigurationAssignment `json:"officeConfigurationAssignments,omitempty"`
    26  }
    27  
    28  // Assignments returns request builder for OfficeClientConfigurationAssignment collection
    29  func (b *OfficeClientConfigurationRequestBuilder) Assignments() *OfficeClientConfigurationAssignmentsCollectionRequestBuilder {
    30  	bb := &OfficeClientConfigurationAssignmentsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    31  	bb.baseURL += "/assignments"
    32  	return bb
    33  }
    34  
    35  // OfficeClientConfigurationAssignmentsCollectionRequestBuilder is request builder for OfficeClientConfigurationAssignment collection
    36  type OfficeClientConfigurationAssignmentsCollectionRequestBuilder struct{ BaseRequestBuilder }
    37  
    38  // Request returns request for OfficeClientConfigurationAssignment collection
    39  func (b *OfficeClientConfigurationAssignmentsCollectionRequestBuilder) Request() *OfficeClientConfigurationAssignmentsCollectionRequest {
    40  	return &OfficeClientConfigurationAssignmentsCollectionRequest{
    41  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
    42  	}
    43  }
    44  
    45  // ID returns request builder for OfficeClientConfigurationAssignment item
    46  func (b *OfficeClientConfigurationAssignmentsCollectionRequestBuilder) ID(id string) *OfficeClientConfigurationAssignmentRequestBuilder {
    47  	bb := &OfficeClientConfigurationAssignmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    48  	bb.baseURL += "/" + id
    49  	return bb
    50  }
    51  
    52  // OfficeClientConfigurationAssignmentsCollectionRequest is request for OfficeClientConfigurationAssignment collection
    53  type OfficeClientConfigurationAssignmentsCollectionRequest struct{ BaseRequest }
    54  
    55  // Paging perfoms paging operation for OfficeClientConfigurationAssignment collection
    56  func (r *OfficeClientConfigurationAssignmentsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]OfficeClientConfigurationAssignment, error) {
    57  	req, err := r.NewJSONRequest(method, path, obj)
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	if ctx != nil {
    62  		req = req.WithContext(ctx)
    63  	}
    64  	res, err := r.client.Do(req)
    65  	if err != nil {
    66  		return nil, err
    67  	}
    68  	var values []OfficeClientConfigurationAssignment
    69  	for {
    70  		if res.StatusCode != http.StatusOK {
    71  			b, _ := ioutil.ReadAll(res.Body)
    72  			res.Body.Close()
    73  			errRes := &ErrorResponse{Response: res}
    74  			err := jsonx.Unmarshal(b, errRes)
    75  			if err != nil {
    76  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
    77  			}
    78  			return nil, errRes
    79  		}
    80  		var (
    81  			paging Paging
    82  			value  []OfficeClientConfigurationAssignment
    83  		)
    84  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
    85  		res.Body.Close()
    86  		if err != nil {
    87  			return nil, err
    88  		}
    89  		err = jsonx.Unmarshal(paging.Value, &value)
    90  		if err != nil {
    91  			return nil, err
    92  		}
    93  		values = append(values, value...)
    94  		if n >= 0 {
    95  			n--
    96  		}
    97  		if n == 0 || len(paging.NextLink) == 0 {
    98  			return values, nil
    99  		}
   100  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   101  		if ctx != nil {
   102  			req = req.WithContext(ctx)
   103  		}
   104  		res, err = r.client.Do(req)
   105  		if err != nil {
   106  			return nil, err
   107  		}
   108  	}
   109  }
   110  
   111  // GetN performs GET request for OfficeClientConfigurationAssignment collection, max N pages
   112  func (r *OfficeClientConfigurationAssignmentsCollectionRequest) GetN(ctx context.Context, n int) ([]OfficeClientConfigurationAssignment, error) {
   113  	var query string
   114  	if r.query != nil {
   115  		query = "?" + r.query.Encode()
   116  	}
   117  	return r.Paging(ctx, "GET", query, nil, n)
   118  }
   119  
   120  // Get performs GET request for OfficeClientConfigurationAssignment collection
   121  func (r *OfficeClientConfigurationAssignmentsCollectionRequest) Get(ctx context.Context) ([]OfficeClientConfigurationAssignment, error) {
   122  	return r.GetN(ctx, 0)
   123  }
   124  
   125  // Add performs POST request for OfficeClientConfigurationAssignment collection
   126  func (r *OfficeClientConfigurationAssignmentsCollectionRequest) Add(ctx context.Context, reqObj *OfficeClientConfigurationAssignment) (resObj *OfficeClientConfigurationAssignment, err error) {
   127  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   128  	return
   129  }
   130  
   131  // ClientConfigurations returns request builder for OfficeClientConfiguration collection
   132  func (b *OfficeConfigurationRequestBuilder) ClientConfigurations() *OfficeConfigurationClientConfigurationsCollectionRequestBuilder {
   133  	bb := &OfficeConfigurationClientConfigurationsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   134  	bb.baseURL += "/clientConfigurations"
   135  	return bb
   136  }
   137  
   138  // OfficeConfigurationClientConfigurationsCollectionRequestBuilder is request builder for OfficeClientConfiguration collection
   139  type OfficeConfigurationClientConfigurationsCollectionRequestBuilder struct{ BaseRequestBuilder }
   140  
   141  // Request returns request for OfficeClientConfiguration collection
   142  func (b *OfficeConfigurationClientConfigurationsCollectionRequestBuilder) Request() *OfficeConfigurationClientConfigurationsCollectionRequest {
   143  	return &OfficeConfigurationClientConfigurationsCollectionRequest{
   144  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   145  	}
   146  }
   147  
   148  // ID returns request builder for OfficeClientConfiguration item
   149  func (b *OfficeConfigurationClientConfigurationsCollectionRequestBuilder) ID(id string) *OfficeClientConfigurationRequestBuilder {
   150  	bb := &OfficeClientConfigurationRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   151  	bb.baseURL += "/" + id
   152  	return bb
   153  }
   154  
   155  // OfficeConfigurationClientConfigurationsCollectionRequest is request for OfficeClientConfiguration collection
   156  type OfficeConfigurationClientConfigurationsCollectionRequest struct{ BaseRequest }
   157  
   158  // Paging perfoms paging operation for OfficeClientConfiguration collection
   159  func (r *OfficeConfigurationClientConfigurationsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]OfficeClientConfiguration, error) {
   160  	req, err := r.NewJSONRequest(method, path, obj)
   161  	if err != nil {
   162  		return nil, err
   163  	}
   164  	if ctx != nil {
   165  		req = req.WithContext(ctx)
   166  	}
   167  	res, err := r.client.Do(req)
   168  	if err != nil {
   169  		return nil, err
   170  	}
   171  	var values []OfficeClientConfiguration
   172  	for {
   173  		if res.StatusCode != http.StatusOK {
   174  			b, _ := ioutil.ReadAll(res.Body)
   175  			res.Body.Close()
   176  			errRes := &ErrorResponse{Response: res}
   177  			err := jsonx.Unmarshal(b, errRes)
   178  			if err != nil {
   179  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   180  			}
   181  			return nil, errRes
   182  		}
   183  		var (
   184  			paging Paging
   185  			value  []OfficeClientConfiguration
   186  		)
   187  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   188  		res.Body.Close()
   189  		if err != nil {
   190  			return nil, err
   191  		}
   192  		err = jsonx.Unmarshal(paging.Value, &value)
   193  		if err != nil {
   194  			return nil, err
   195  		}
   196  		values = append(values, value...)
   197  		if n >= 0 {
   198  			n--
   199  		}
   200  		if n == 0 || len(paging.NextLink) == 0 {
   201  			return values, nil
   202  		}
   203  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   204  		if ctx != nil {
   205  			req = req.WithContext(ctx)
   206  		}
   207  		res, err = r.client.Do(req)
   208  		if err != nil {
   209  			return nil, err
   210  		}
   211  	}
   212  }
   213  
   214  // GetN performs GET request for OfficeClientConfiguration collection, max N pages
   215  func (r *OfficeConfigurationClientConfigurationsCollectionRequest) GetN(ctx context.Context, n int) ([]OfficeClientConfiguration, error) {
   216  	var query string
   217  	if r.query != nil {
   218  		query = "?" + r.query.Encode()
   219  	}
   220  	return r.Paging(ctx, "GET", query, nil, n)
   221  }
   222  
   223  // Get performs GET request for OfficeClientConfiguration collection
   224  func (r *OfficeConfigurationClientConfigurationsCollectionRequest) Get(ctx context.Context) ([]OfficeClientConfiguration, error) {
   225  	return r.GetN(ctx, 0)
   226  }
   227  
   228  // Add performs POST request for OfficeClientConfiguration collection
   229  func (r *OfficeConfigurationClientConfigurationsCollectionRequest) Add(ctx context.Context, reqObj *OfficeClientConfiguration) (resObj *OfficeClientConfiguration, err error) {
   230  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   231  	return
   232  }
   233  
   234  // Shared returns request builder for SharedInsight collection
   235  func (b *OfficeGraphInsightsRequestBuilder) Shared() *OfficeGraphInsightsSharedCollectionRequestBuilder {
   236  	bb := &OfficeGraphInsightsSharedCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   237  	bb.baseURL += "/shared"
   238  	return bb
   239  }
   240  
   241  // OfficeGraphInsightsSharedCollectionRequestBuilder is request builder for SharedInsight collection
   242  type OfficeGraphInsightsSharedCollectionRequestBuilder struct{ BaseRequestBuilder }
   243  
   244  // Request returns request for SharedInsight collection
   245  func (b *OfficeGraphInsightsSharedCollectionRequestBuilder) Request() *OfficeGraphInsightsSharedCollectionRequest {
   246  	return &OfficeGraphInsightsSharedCollectionRequest{
   247  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   248  	}
   249  }
   250  
   251  // ID returns request builder for SharedInsight item
   252  func (b *OfficeGraphInsightsSharedCollectionRequestBuilder) ID(id string) *SharedInsightRequestBuilder {
   253  	bb := &SharedInsightRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   254  	bb.baseURL += "/" + id
   255  	return bb
   256  }
   257  
   258  // OfficeGraphInsightsSharedCollectionRequest is request for SharedInsight collection
   259  type OfficeGraphInsightsSharedCollectionRequest struct{ BaseRequest }
   260  
   261  // Paging perfoms paging operation for SharedInsight collection
   262  func (r *OfficeGraphInsightsSharedCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]SharedInsight, error) {
   263  	req, err := r.NewJSONRequest(method, path, obj)
   264  	if err != nil {
   265  		return nil, err
   266  	}
   267  	if ctx != nil {
   268  		req = req.WithContext(ctx)
   269  	}
   270  	res, err := r.client.Do(req)
   271  	if err != nil {
   272  		return nil, err
   273  	}
   274  	var values []SharedInsight
   275  	for {
   276  		if res.StatusCode != http.StatusOK {
   277  			b, _ := ioutil.ReadAll(res.Body)
   278  			res.Body.Close()
   279  			errRes := &ErrorResponse{Response: res}
   280  			err := jsonx.Unmarshal(b, errRes)
   281  			if err != nil {
   282  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   283  			}
   284  			return nil, errRes
   285  		}
   286  		var (
   287  			paging Paging
   288  			value  []SharedInsight
   289  		)
   290  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   291  		res.Body.Close()
   292  		if err != nil {
   293  			return nil, err
   294  		}
   295  		err = jsonx.Unmarshal(paging.Value, &value)
   296  		if err != nil {
   297  			return nil, err
   298  		}
   299  		values = append(values, value...)
   300  		if n >= 0 {
   301  			n--
   302  		}
   303  		if n == 0 || len(paging.NextLink) == 0 {
   304  			return values, nil
   305  		}
   306  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   307  		if ctx != nil {
   308  			req = req.WithContext(ctx)
   309  		}
   310  		res, err = r.client.Do(req)
   311  		if err != nil {
   312  			return nil, err
   313  		}
   314  	}
   315  }
   316  
   317  // GetN performs GET request for SharedInsight collection, max N pages
   318  func (r *OfficeGraphInsightsSharedCollectionRequest) GetN(ctx context.Context, n int) ([]SharedInsight, error) {
   319  	var query string
   320  	if r.query != nil {
   321  		query = "?" + r.query.Encode()
   322  	}
   323  	return r.Paging(ctx, "GET", query, nil, n)
   324  }
   325  
   326  // Get performs GET request for SharedInsight collection
   327  func (r *OfficeGraphInsightsSharedCollectionRequest) Get(ctx context.Context) ([]SharedInsight, error) {
   328  	return r.GetN(ctx, 0)
   329  }
   330  
   331  // Add performs POST request for SharedInsight collection
   332  func (r *OfficeGraphInsightsSharedCollectionRequest) Add(ctx context.Context, reqObj *SharedInsight) (resObj *SharedInsight, err error) {
   333  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   334  	return
   335  }
   336  
   337  // Trending returns request builder for Trending collection
   338  func (b *OfficeGraphInsightsRequestBuilder) Trending() *OfficeGraphInsightsTrendingCollectionRequestBuilder {
   339  	bb := &OfficeGraphInsightsTrendingCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   340  	bb.baseURL += "/trending"
   341  	return bb
   342  }
   343  
   344  // OfficeGraphInsightsTrendingCollectionRequestBuilder is request builder for Trending collection
   345  type OfficeGraphInsightsTrendingCollectionRequestBuilder struct{ BaseRequestBuilder }
   346  
   347  // Request returns request for Trending collection
   348  func (b *OfficeGraphInsightsTrendingCollectionRequestBuilder) Request() *OfficeGraphInsightsTrendingCollectionRequest {
   349  	return &OfficeGraphInsightsTrendingCollectionRequest{
   350  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   351  	}
   352  }
   353  
   354  // ID returns request builder for Trending item
   355  func (b *OfficeGraphInsightsTrendingCollectionRequestBuilder) ID(id string) *TrendingRequestBuilder {
   356  	bb := &TrendingRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   357  	bb.baseURL += "/" + id
   358  	return bb
   359  }
   360  
   361  // OfficeGraphInsightsTrendingCollectionRequest is request for Trending collection
   362  type OfficeGraphInsightsTrendingCollectionRequest struct{ BaseRequest }
   363  
   364  // Paging perfoms paging operation for Trending collection
   365  func (r *OfficeGraphInsightsTrendingCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]Trending, error) {
   366  	req, err := r.NewJSONRequest(method, path, obj)
   367  	if err != nil {
   368  		return nil, err
   369  	}
   370  	if ctx != nil {
   371  		req = req.WithContext(ctx)
   372  	}
   373  	res, err := r.client.Do(req)
   374  	if err != nil {
   375  		return nil, err
   376  	}
   377  	var values []Trending
   378  	for {
   379  		if res.StatusCode != http.StatusOK {
   380  			b, _ := ioutil.ReadAll(res.Body)
   381  			res.Body.Close()
   382  			errRes := &ErrorResponse{Response: res}
   383  			err := jsonx.Unmarshal(b, errRes)
   384  			if err != nil {
   385  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   386  			}
   387  			return nil, errRes
   388  		}
   389  		var (
   390  			paging Paging
   391  			value  []Trending
   392  		)
   393  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   394  		res.Body.Close()
   395  		if err != nil {
   396  			return nil, err
   397  		}
   398  		err = jsonx.Unmarshal(paging.Value, &value)
   399  		if err != nil {
   400  			return nil, err
   401  		}
   402  		values = append(values, value...)
   403  		if n >= 0 {
   404  			n--
   405  		}
   406  		if n == 0 || len(paging.NextLink) == 0 {
   407  			return values, nil
   408  		}
   409  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   410  		if ctx != nil {
   411  			req = req.WithContext(ctx)
   412  		}
   413  		res, err = r.client.Do(req)
   414  		if err != nil {
   415  			return nil, err
   416  		}
   417  	}
   418  }
   419  
   420  // GetN performs GET request for Trending collection, max N pages
   421  func (r *OfficeGraphInsightsTrendingCollectionRequest) GetN(ctx context.Context, n int) ([]Trending, error) {
   422  	var query string
   423  	if r.query != nil {
   424  		query = "?" + r.query.Encode()
   425  	}
   426  	return r.Paging(ctx, "GET", query, nil, n)
   427  }
   428  
   429  // Get performs GET request for Trending collection
   430  func (r *OfficeGraphInsightsTrendingCollectionRequest) Get(ctx context.Context) ([]Trending, error) {
   431  	return r.GetN(ctx, 0)
   432  }
   433  
   434  // Add performs POST request for Trending collection
   435  func (r *OfficeGraphInsightsTrendingCollectionRequest) Add(ctx context.Context, reqObj *Trending) (resObj *Trending, err error) {
   436  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   437  	return
   438  }
   439  
   440  // Used returns request builder for UsedInsight collection
   441  func (b *OfficeGraphInsightsRequestBuilder) Used() *OfficeGraphInsightsUsedCollectionRequestBuilder {
   442  	bb := &OfficeGraphInsightsUsedCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   443  	bb.baseURL += "/used"
   444  	return bb
   445  }
   446  
   447  // OfficeGraphInsightsUsedCollectionRequestBuilder is request builder for UsedInsight collection
   448  type OfficeGraphInsightsUsedCollectionRequestBuilder struct{ BaseRequestBuilder }
   449  
   450  // Request returns request for UsedInsight collection
   451  func (b *OfficeGraphInsightsUsedCollectionRequestBuilder) Request() *OfficeGraphInsightsUsedCollectionRequest {
   452  	return &OfficeGraphInsightsUsedCollectionRequest{
   453  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   454  	}
   455  }
   456  
   457  // ID returns request builder for UsedInsight item
   458  func (b *OfficeGraphInsightsUsedCollectionRequestBuilder) ID(id string) *UsedInsightRequestBuilder {
   459  	bb := &UsedInsightRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   460  	bb.baseURL += "/" + id
   461  	return bb
   462  }
   463  
   464  // OfficeGraphInsightsUsedCollectionRequest is request for UsedInsight collection
   465  type OfficeGraphInsightsUsedCollectionRequest struct{ BaseRequest }
   466  
   467  // Paging perfoms paging operation for UsedInsight collection
   468  func (r *OfficeGraphInsightsUsedCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]UsedInsight, error) {
   469  	req, err := r.NewJSONRequest(method, path, obj)
   470  	if err != nil {
   471  		return nil, err
   472  	}
   473  	if ctx != nil {
   474  		req = req.WithContext(ctx)
   475  	}
   476  	res, err := r.client.Do(req)
   477  	if err != nil {
   478  		return nil, err
   479  	}
   480  	var values []UsedInsight
   481  	for {
   482  		if res.StatusCode != http.StatusOK {
   483  			b, _ := ioutil.ReadAll(res.Body)
   484  			res.Body.Close()
   485  			errRes := &ErrorResponse{Response: res}
   486  			err := jsonx.Unmarshal(b, errRes)
   487  			if err != nil {
   488  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   489  			}
   490  			return nil, errRes
   491  		}
   492  		var (
   493  			paging Paging
   494  			value  []UsedInsight
   495  		)
   496  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   497  		res.Body.Close()
   498  		if err != nil {
   499  			return nil, err
   500  		}
   501  		err = jsonx.Unmarshal(paging.Value, &value)
   502  		if err != nil {
   503  			return nil, err
   504  		}
   505  		values = append(values, value...)
   506  		if n >= 0 {
   507  			n--
   508  		}
   509  		if n == 0 || len(paging.NextLink) == 0 {
   510  			return values, nil
   511  		}
   512  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   513  		if ctx != nil {
   514  			req = req.WithContext(ctx)
   515  		}
   516  		res, err = r.client.Do(req)
   517  		if err != nil {
   518  			return nil, err
   519  		}
   520  	}
   521  }
   522  
   523  // GetN performs GET request for UsedInsight collection, max N pages
   524  func (r *OfficeGraphInsightsUsedCollectionRequest) GetN(ctx context.Context, n int) ([]UsedInsight, error) {
   525  	var query string
   526  	if r.query != nil {
   527  		query = "?" + r.query.Encode()
   528  	}
   529  	return r.Paging(ctx, "GET", query, nil, n)
   530  }
   531  
   532  // Get performs GET request for UsedInsight collection
   533  func (r *OfficeGraphInsightsUsedCollectionRequest) Get(ctx context.Context) ([]UsedInsight, error) {
   534  	return r.GetN(ctx, 0)
   535  }
   536  
   537  // Add performs POST request for UsedInsight collection
   538  func (r *OfficeGraphInsightsUsedCollectionRequest) Add(ctx context.Context, reqObj *UsedInsight) (resObj *UsedInsight, err error) {
   539  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   540  	return
   541  }