github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionImported.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 // ImportedAppleDeviceIdentityCollectionImportAppleDeviceIdentityListRequestParameter undocumented 15 type ImportedAppleDeviceIdentityCollectionImportAppleDeviceIdentityListRequestParameter struct { 16 // ImportedAppleDeviceIdentities undocumented 17 ImportedAppleDeviceIdentities []ImportedAppleDeviceIdentity `json:"importedAppleDeviceIdentities,omitempty"` 18 // OverwriteImportedDeviceIdentities undocumented 19 OverwriteImportedDeviceIdentities *bool `json:"overwriteImportedDeviceIdentities,omitempty"` 20 } 21 22 // ImportedDeviceIdentityCollectionImportDeviceIdentityListRequestParameter undocumented 23 type ImportedDeviceIdentityCollectionImportDeviceIdentityListRequestParameter struct { 24 // ImportedDeviceIdentities undocumented 25 ImportedDeviceIdentities []ImportedDeviceIdentity `json:"importedDeviceIdentities,omitempty"` 26 // OverwriteImportedDeviceIdentities undocumented 27 OverwriteImportedDeviceIdentities *bool `json:"overwriteImportedDeviceIdentities,omitempty"` 28 } 29 30 // ImportedDeviceIdentityCollectionSearchExistingIdentitiesRequestParameter undocumented 31 type ImportedDeviceIdentityCollectionSearchExistingIdentitiesRequestParameter struct { 32 // ImportedDeviceIdentities undocumented 33 ImportedDeviceIdentities []ImportedDeviceIdentity `json:"importedDeviceIdentities,omitempty"` 34 } 35 36 // ImportedWindowsAutopilotDeviceIdentityCollectionImportRequestParameter undocumented 37 type ImportedWindowsAutopilotDeviceIdentityCollectionImportRequestParameter struct { 38 // ImportedWindowsAutopilotDeviceIdentities undocumented 39 ImportedWindowsAutopilotDeviceIdentities []ImportedWindowsAutopilotDeviceIdentity `json:"importedWindowsAutopilotDeviceIdentities,omitempty"` 40 } 41 42 // DeviceIdentities returns request builder for ImportedWindowsAutopilotDeviceIdentity collection 43 func (b *ImportedWindowsAutopilotDeviceIdentityUploadRequestBuilder) DeviceIdentities() *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder { 44 bb := &ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 45 bb.baseURL += "/deviceIdentities" 46 return bb 47 } 48 49 // ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder is request builder for ImportedWindowsAutopilotDeviceIdentity collection 50 type ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder struct{ BaseRequestBuilder } 51 52 // Request returns request for ImportedWindowsAutopilotDeviceIdentity collection 53 func (b *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder) Request() *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest { 54 return &ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest{ 55 BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, 56 } 57 } 58 59 // ID returns request builder for ImportedWindowsAutopilotDeviceIdentity item 60 func (b *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequestBuilder) ID(id string) *ImportedWindowsAutopilotDeviceIdentityRequestBuilder { 61 bb := &ImportedWindowsAutopilotDeviceIdentityRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 62 bb.baseURL += "/" + id 63 return bb 64 } 65 66 // ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest is request for ImportedWindowsAutopilotDeviceIdentity collection 67 type ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest struct{ BaseRequest } 68 69 // Paging perfoms paging operation for ImportedWindowsAutopilotDeviceIdentity collection 70 func (r *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]ImportedWindowsAutopilotDeviceIdentity, error) { 71 req, err := r.NewJSONRequest(method, path, obj) 72 if err != nil { 73 return nil, err 74 } 75 if ctx != nil { 76 req = req.WithContext(ctx) 77 } 78 res, err := r.client.Do(req) 79 if err != nil { 80 return nil, err 81 } 82 var values []ImportedWindowsAutopilotDeviceIdentity 83 for { 84 if res.StatusCode != http.StatusOK { 85 b, _ := ioutil.ReadAll(res.Body) 86 res.Body.Close() 87 errRes := &ErrorResponse{Response: res} 88 err := jsonx.Unmarshal(b, errRes) 89 if err != nil { 90 return nil, fmt.Errorf("%s: %s", res.Status, string(b)) 91 } 92 return nil, errRes 93 } 94 var ( 95 paging Paging 96 value []ImportedWindowsAutopilotDeviceIdentity 97 ) 98 err := jsonx.NewDecoder(res.Body).Decode(&paging) 99 res.Body.Close() 100 if err != nil { 101 return nil, err 102 } 103 err = jsonx.Unmarshal(paging.Value, &value) 104 if err != nil { 105 return nil, err 106 } 107 values = append(values, value...) 108 if n >= 0 { 109 n-- 110 } 111 if n == 0 || len(paging.NextLink) == 0 { 112 return values, nil 113 } 114 req, err = http.NewRequest("GET", paging.NextLink, nil) 115 if ctx != nil { 116 req = req.WithContext(ctx) 117 } 118 res, err = r.client.Do(req) 119 if err != nil { 120 return nil, err 121 } 122 } 123 } 124 125 // GetN performs GET request for ImportedWindowsAutopilotDeviceIdentity collection, max N pages 126 func (r *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest) GetN(ctx context.Context, n int) ([]ImportedWindowsAutopilotDeviceIdentity, error) { 127 var query string 128 if r.query != nil { 129 query = "?" + r.query.Encode() 130 } 131 return r.Paging(ctx, "GET", query, nil, n) 132 } 133 134 // Get performs GET request for ImportedWindowsAutopilotDeviceIdentity collection 135 func (r *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest) Get(ctx context.Context) ([]ImportedWindowsAutopilotDeviceIdentity, error) { 136 return r.GetN(ctx, 0) 137 } 138 139 // Add performs POST request for ImportedWindowsAutopilotDeviceIdentity collection 140 func (r *ImportedWindowsAutopilotDeviceIdentityUploadDeviceIdentitiesCollectionRequest) Add(ctx context.Context, reqObj *ImportedWindowsAutopilotDeviceIdentity) (resObj *ImportedWindowsAutopilotDeviceIdentity, err error) { 141 err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) 142 return 143 }