github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionApp.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  // AppLogCollectionRequestObjectCreateDownloadURLRequestParameter undocumented
    15  type AppLogCollectionRequestObjectCreateDownloadURLRequestParameter struct {
    16  }
    17  
    18  // TeamsApps returns request builder for TeamsApp collection
    19  func (b *AppCatalogsRequestBuilder) TeamsApps() *AppCatalogsTeamsAppsCollectionRequestBuilder {
    20  	bb := &AppCatalogsTeamsAppsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    21  	bb.baseURL += "/teamsApps"
    22  	return bb
    23  }
    24  
    25  // AppCatalogsTeamsAppsCollectionRequestBuilder is request builder for TeamsApp collection
    26  type AppCatalogsTeamsAppsCollectionRequestBuilder struct{ BaseRequestBuilder }
    27  
    28  // Request returns request for TeamsApp collection
    29  func (b *AppCatalogsTeamsAppsCollectionRequestBuilder) Request() *AppCatalogsTeamsAppsCollectionRequest {
    30  	return &AppCatalogsTeamsAppsCollectionRequest{
    31  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
    32  	}
    33  }
    34  
    35  // ID returns request builder for TeamsApp item
    36  func (b *AppCatalogsTeamsAppsCollectionRequestBuilder) ID(id string) *TeamsAppRequestBuilder {
    37  	bb := &TeamsAppRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    38  	bb.baseURL += "/" + id
    39  	return bb
    40  }
    41  
    42  // AppCatalogsTeamsAppsCollectionRequest is request for TeamsApp collection
    43  type AppCatalogsTeamsAppsCollectionRequest struct{ BaseRequest }
    44  
    45  // Paging perfoms paging operation for TeamsApp collection
    46  func (r *AppCatalogsTeamsAppsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]TeamsApp, error) {
    47  	req, err := r.NewJSONRequest(method, path, obj)
    48  	if err != nil {
    49  		return nil, err
    50  	}
    51  	if ctx != nil {
    52  		req = req.WithContext(ctx)
    53  	}
    54  	res, err := r.client.Do(req)
    55  	if err != nil {
    56  		return nil, err
    57  	}
    58  	var values []TeamsApp
    59  	for {
    60  		if res.StatusCode != http.StatusOK {
    61  			b, _ := ioutil.ReadAll(res.Body)
    62  			res.Body.Close()
    63  			errRes := &ErrorResponse{Response: res}
    64  			err := jsonx.Unmarshal(b, errRes)
    65  			if err != nil {
    66  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
    67  			}
    68  			return nil, errRes
    69  		}
    70  		var (
    71  			paging Paging
    72  			value  []TeamsApp
    73  		)
    74  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
    75  		res.Body.Close()
    76  		if err != nil {
    77  			return nil, err
    78  		}
    79  		err = jsonx.Unmarshal(paging.Value, &value)
    80  		if err != nil {
    81  			return nil, err
    82  		}
    83  		values = append(values, value...)
    84  		if n >= 0 {
    85  			n--
    86  		}
    87  		if n == 0 || len(paging.NextLink) == 0 {
    88  			return values, nil
    89  		}
    90  		req, err = http.NewRequest("GET", paging.NextLink, nil)
    91  		if ctx != nil {
    92  			req = req.WithContext(ctx)
    93  		}
    94  		res, err = r.client.Do(req)
    95  		if err != nil {
    96  			return nil, err
    97  		}
    98  	}
    99  }
   100  
   101  // GetN performs GET request for TeamsApp collection, max N pages
   102  func (r *AppCatalogsTeamsAppsCollectionRequest) GetN(ctx context.Context, n int) ([]TeamsApp, error) {
   103  	var query string
   104  	if r.query != nil {
   105  		query = "?" + r.query.Encode()
   106  	}
   107  	return r.Paging(ctx, "GET", query, nil, n)
   108  }
   109  
   110  // Get performs GET request for TeamsApp collection
   111  func (r *AppCatalogsTeamsAppsCollectionRequest) Get(ctx context.Context) ([]TeamsApp, error) {
   112  	return r.GetN(ctx, 0)
   113  }
   114  
   115  // Add performs POST request for TeamsApp collection
   116  func (r *AppCatalogsTeamsAppsCollectionRequest) Add(ctx context.Context, reqObj *TeamsApp) (resObj *TeamsApp, err error) {
   117  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   118  	return
   119  }
   120  
   121  // ManagedDevices returns request builder for AppVulnerabilityManagedDevice collection
   122  func (b *AppVulnerabilityTaskRequestBuilder) ManagedDevices() *AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder {
   123  	bb := &AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   124  	bb.baseURL += "/managedDevices"
   125  	return bb
   126  }
   127  
   128  // AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder is request builder for AppVulnerabilityManagedDevice collection
   129  type AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder struct{ BaseRequestBuilder }
   130  
   131  // Request returns request for AppVulnerabilityManagedDevice collection
   132  func (b *AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder) Request() *AppVulnerabilityTaskManagedDevicesCollectionRequest {
   133  	return &AppVulnerabilityTaskManagedDevicesCollectionRequest{
   134  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   135  	}
   136  }
   137  
   138  // ID returns request builder for AppVulnerabilityManagedDevice item
   139  func (b *AppVulnerabilityTaskManagedDevicesCollectionRequestBuilder) ID(id string) *AppVulnerabilityManagedDeviceRequestBuilder {
   140  	bb := &AppVulnerabilityManagedDeviceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   141  	bb.baseURL += "/" + id
   142  	return bb
   143  }
   144  
   145  // AppVulnerabilityTaskManagedDevicesCollectionRequest is request for AppVulnerabilityManagedDevice collection
   146  type AppVulnerabilityTaskManagedDevicesCollectionRequest struct{ BaseRequest }
   147  
   148  // Paging perfoms paging operation for AppVulnerabilityManagedDevice collection
   149  func (r *AppVulnerabilityTaskManagedDevicesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]AppVulnerabilityManagedDevice, error) {
   150  	req, err := r.NewJSONRequest(method, path, obj)
   151  	if err != nil {
   152  		return nil, err
   153  	}
   154  	if ctx != nil {
   155  		req = req.WithContext(ctx)
   156  	}
   157  	res, err := r.client.Do(req)
   158  	if err != nil {
   159  		return nil, err
   160  	}
   161  	var values []AppVulnerabilityManagedDevice
   162  	for {
   163  		if res.StatusCode != http.StatusOK {
   164  			b, _ := ioutil.ReadAll(res.Body)
   165  			res.Body.Close()
   166  			errRes := &ErrorResponse{Response: res}
   167  			err := jsonx.Unmarshal(b, errRes)
   168  			if err != nil {
   169  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   170  			}
   171  			return nil, errRes
   172  		}
   173  		var (
   174  			paging Paging
   175  			value  []AppVulnerabilityManagedDevice
   176  		)
   177  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   178  		res.Body.Close()
   179  		if err != nil {
   180  			return nil, err
   181  		}
   182  		err = jsonx.Unmarshal(paging.Value, &value)
   183  		if err != nil {
   184  			return nil, err
   185  		}
   186  		values = append(values, value...)
   187  		if n >= 0 {
   188  			n--
   189  		}
   190  		if n == 0 || len(paging.NextLink) == 0 {
   191  			return values, nil
   192  		}
   193  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   194  		if ctx != nil {
   195  			req = req.WithContext(ctx)
   196  		}
   197  		res, err = r.client.Do(req)
   198  		if err != nil {
   199  			return nil, err
   200  		}
   201  	}
   202  }
   203  
   204  // GetN performs GET request for AppVulnerabilityManagedDevice collection, max N pages
   205  func (r *AppVulnerabilityTaskManagedDevicesCollectionRequest) GetN(ctx context.Context, n int) ([]AppVulnerabilityManagedDevice, error) {
   206  	var query string
   207  	if r.query != nil {
   208  		query = "?" + r.query.Encode()
   209  	}
   210  	return r.Paging(ctx, "GET", query, nil, n)
   211  }
   212  
   213  // Get performs GET request for AppVulnerabilityManagedDevice collection
   214  func (r *AppVulnerabilityTaskManagedDevicesCollectionRequest) Get(ctx context.Context) ([]AppVulnerabilityManagedDevice, error) {
   215  	return r.GetN(ctx, 0)
   216  }
   217  
   218  // Add performs POST request for AppVulnerabilityManagedDevice collection
   219  func (r *AppVulnerabilityTaskManagedDevicesCollectionRequest) Add(ctx context.Context, reqObj *AppVulnerabilityManagedDevice) (resObj *AppVulnerabilityManagedDevice, err error) {
   220  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   221  	return
   222  }
   223  
   224  // MobileApps returns request builder for AppVulnerabilityMobileApp collection
   225  func (b *AppVulnerabilityTaskRequestBuilder) MobileApps() *AppVulnerabilityTaskMobileAppsCollectionRequestBuilder {
   226  	bb := &AppVulnerabilityTaskMobileAppsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   227  	bb.baseURL += "/mobileApps"
   228  	return bb
   229  }
   230  
   231  // AppVulnerabilityTaskMobileAppsCollectionRequestBuilder is request builder for AppVulnerabilityMobileApp collection
   232  type AppVulnerabilityTaskMobileAppsCollectionRequestBuilder struct{ BaseRequestBuilder }
   233  
   234  // Request returns request for AppVulnerabilityMobileApp collection
   235  func (b *AppVulnerabilityTaskMobileAppsCollectionRequestBuilder) Request() *AppVulnerabilityTaskMobileAppsCollectionRequest {
   236  	return &AppVulnerabilityTaskMobileAppsCollectionRequest{
   237  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   238  	}
   239  }
   240  
   241  // ID returns request builder for AppVulnerabilityMobileApp item
   242  func (b *AppVulnerabilityTaskMobileAppsCollectionRequestBuilder) ID(id string) *AppVulnerabilityMobileAppRequestBuilder {
   243  	bb := &AppVulnerabilityMobileAppRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   244  	bb.baseURL += "/" + id
   245  	return bb
   246  }
   247  
   248  // AppVulnerabilityTaskMobileAppsCollectionRequest is request for AppVulnerabilityMobileApp collection
   249  type AppVulnerabilityTaskMobileAppsCollectionRequest struct{ BaseRequest }
   250  
   251  // Paging perfoms paging operation for AppVulnerabilityMobileApp collection
   252  func (r *AppVulnerabilityTaskMobileAppsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]AppVulnerabilityMobileApp, error) {
   253  	req, err := r.NewJSONRequest(method, path, obj)
   254  	if err != nil {
   255  		return nil, err
   256  	}
   257  	if ctx != nil {
   258  		req = req.WithContext(ctx)
   259  	}
   260  	res, err := r.client.Do(req)
   261  	if err != nil {
   262  		return nil, err
   263  	}
   264  	var values []AppVulnerabilityMobileApp
   265  	for {
   266  		if res.StatusCode != http.StatusOK {
   267  			b, _ := ioutil.ReadAll(res.Body)
   268  			res.Body.Close()
   269  			errRes := &ErrorResponse{Response: res}
   270  			err := jsonx.Unmarshal(b, errRes)
   271  			if err != nil {
   272  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   273  			}
   274  			return nil, errRes
   275  		}
   276  		var (
   277  			paging Paging
   278  			value  []AppVulnerabilityMobileApp
   279  		)
   280  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   281  		res.Body.Close()
   282  		if err != nil {
   283  			return nil, err
   284  		}
   285  		err = jsonx.Unmarshal(paging.Value, &value)
   286  		if err != nil {
   287  			return nil, err
   288  		}
   289  		values = append(values, value...)
   290  		if n >= 0 {
   291  			n--
   292  		}
   293  		if n == 0 || len(paging.NextLink) == 0 {
   294  			return values, nil
   295  		}
   296  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   297  		if ctx != nil {
   298  			req = req.WithContext(ctx)
   299  		}
   300  		res, err = r.client.Do(req)
   301  		if err != nil {
   302  			return nil, err
   303  		}
   304  	}
   305  }
   306  
   307  // GetN performs GET request for AppVulnerabilityMobileApp collection, max N pages
   308  func (r *AppVulnerabilityTaskMobileAppsCollectionRequest) GetN(ctx context.Context, n int) ([]AppVulnerabilityMobileApp, error) {
   309  	var query string
   310  	if r.query != nil {
   311  		query = "?" + r.query.Encode()
   312  	}
   313  	return r.Paging(ctx, "GET", query, nil, n)
   314  }
   315  
   316  // Get performs GET request for AppVulnerabilityMobileApp collection
   317  func (r *AppVulnerabilityTaskMobileAppsCollectionRequest) Get(ctx context.Context) ([]AppVulnerabilityMobileApp, error) {
   318  	return r.GetN(ctx, 0)
   319  }
   320  
   321  // Add performs POST request for AppVulnerabilityMobileApp collection
   322  func (r *AppVulnerabilityTaskMobileAppsCollectionRequest) Add(ctx context.Context, reqObj *AppVulnerabilityMobileApp) (resObj *AppVulnerabilityMobileApp, err error) {
   323  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   324  	return
   325  }