github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionApplication.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 // ApplicationAddKeyRequestParameter undocumented 15 type ApplicationAddKeyRequestParameter struct { 16 // KeyCredential undocumented 17 KeyCredential *KeyCredential `json:"keyCredential,omitempty"` 18 // PasswordCredential undocumented 19 PasswordCredential *PasswordCredential `json:"passwordCredential,omitempty"` 20 // Proof undocumented 21 Proof *string `json:"proof,omitempty"` 22 } 23 24 // ApplicationAddPasswordRequestParameter undocumented 25 type ApplicationAddPasswordRequestParameter struct { 26 // PasswordCredential undocumented 27 PasswordCredential *PasswordCredential `json:"passwordCredential,omitempty"` 28 } 29 30 // ApplicationRemoveKeyRequestParameter undocumented 31 type ApplicationRemoveKeyRequestParameter struct { 32 // KeyID undocumented 33 KeyID *UUID `json:"keyId,omitempty"` 34 // Proof undocumented 35 Proof *string `json:"proof,omitempty"` 36 } 37 38 // ApplicationRemovePasswordRequestParameter undocumented 39 type ApplicationRemovePasswordRequestParameter struct { 40 // KeyID undocumented 41 KeyID *UUID `json:"keyId,omitempty"` 42 } 43 44 // ApplicationTemplateInstantiateRequestParameter undocumented 45 type ApplicationTemplateInstantiateRequestParameter struct { 46 // DisplayName undocumented 47 DisplayName *string `json:"displayName,omitempty"` 48 } 49 50 // CreatedOnBehalfOf is navigation property 51 func (b *ApplicationRequestBuilder) CreatedOnBehalfOf() *DirectoryObjectRequestBuilder { 52 bb := &DirectoryObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 53 bb.baseURL += "/createdOnBehalfOf" 54 return bb 55 } 56 57 // ExtensionProperties returns request builder for ExtensionProperty collection 58 func (b *ApplicationRequestBuilder) ExtensionProperties() *ApplicationExtensionPropertiesCollectionRequestBuilder { 59 bb := &ApplicationExtensionPropertiesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 60 bb.baseURL += "/extensionProperties" 61 return bb 62 } 63 64 // ApplicationExtensionPropertiesCollectionRequestBuilder is request builder for ExtensionProperty collection 65 type ApplicationExtensionPropertiesCollectionRequestBuilder struct{ BaseRequestBuilder } 66 67 // Request returns request for ExtensionProperty collection 68 func (b *ApplicationExtensionPropertiesCollectionRequestBuilder) Request() *ApplicationExtensionPropertiesCollectionRequest { 69 return &ApplicationExtensionPropertiesCollectionRequest{ 70 BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, 71 } 72 } 73 74 // ID returns request builder for ExtensionProperty item 75 func (b *ApplicationExtensionPropertiesCollectionRequestBuilder) ID(id string) *ExtensionPropertyRequestBuilder { 76 bb := &ExtensionPropertyRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 77 bb.baseURL += "/" + id 78 return bb 79 } 80 81 // ApplicationExtensionPropertiesCollectionRequest is request for ExtensionProperty collection 82 type ApplicationExtensionPropertiesCollectionRequest struct{ BaseRequest } 83 84 // Paging perfoms paging operation for ExtensionProperty collection 85 func (r *ApplicationExtensionPropertiesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]ExtensionProperty, error) { 86 req, err := r.NewJSONRequest(method, path, obj) 87 if err != nil { 88 return nil, err 89 } 90 if ctx != nil { 91 req = req.WithContext(ctx) 92 } 93 res, err := r.client.Do(req) 94 if err != nil { 95 return nil, err 96 } 97 var values []ExtensionProperty 98 for { 99 if res.StatusCode != http.StatusOK { 100 b, _ := ioutil.ReadAll(res.Body) 101 res.Body.Close() 102 errRes := &ErrorResponse{Response: res} 103 err := jsonx.Unmarshal(b, errRes) 104 if err != nil { 105 return nil, fmt.Errorf("%s: %s", res.Status, string(b)) 106 } 107 return nil, errRes 108 } 109 var ( 110 paging Paging 111 value []ExtensionProperty 112 ) 113 err := jsonx.NewDecoder(res.Body).Decode(&paging) 114 res.Body.Close() 115 if err != nil { 116 return nil, err 117 } 118 err = jsonx.Unmarshal(paging.Value, &value) 119 if err != nil { 120 return nil, err 121 } 122 values = append(values, value...) 123 if n >= 0 { 124 n-- 125 } 126 if n == 0 || len(paging.NextLink) == 0 { 127 return values, nil 128 } 129 req, err = http.NewRequest("GET", paging.NextLink, nil) 130 if ctx != nil { 131 req = req.WithContext(ctx) 132 } 133 res, err = r.client.Do(req) 134 if err != nil { 135 return nil, err 136 } 137 } 138 } 139 140 // GetN performs GET request for ExtensionProperty collection, max N pages 141 func (r *ApplicationExtensionPropertiesCollectionRequest) GetN(ctx context.Context, n int) ([]ExtensionProperty, error) { 142 var query string 143 if r.query != nil { 144 query = "?" + r.query.Encode() 145 } 146 return r.Paging(ctx, "GET", query, nil, n) 147 } 148 149 // Get performs GET request for ExtensionProperty collection 150 func (r *ApplicationExtensionPropertiesCollectionRequest) Get(ctx context.Context) ([]ExtensionProperty, error) { 151 return r.GetN(ctx, 0) 152 } 153 154 // Add performs POST request for ExtensionProperty collection 155 func (r *ApplicationExtensionPropertiesCollectionRequest) Add(ctx context.Context, reqObj *ExtensionProperty) (resObj *ExtensionProperty, err error) { 156 err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) 157 return 158 } 159 160 // Owners returns request builder for DirectoryObject collection 161 func (b *ApplicationRequestBuilder) Owners() *ApplicationOwnersCollectionRequestBuilder { 162 bb := &ApplicationOwnersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 163 bb.baseURL += "/owners" 164 return bb 165 } 166 167 // ApplicationOwnersCollectionRequestBuilder is request builder for DirectoryObject collection 168 type ApplicationOwnersCollectionRequestBuilder struct{ BaseRequestBuilder } 169 170 // Request returns request for DirectoryObject collection 171 func (b *ApplicationOwnersCollectionRequestBuilder) Request() *ApplicationOwnersCollectionRequest { 172 return &ApplicationOwnersCollectionRequest{ 173 BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, 174 } 175 } 176 177 // ID returns request builder for DirectoryObject item 178 func (b *ApplicationOwnersCollectionRequestBuilder) ID(id string) *DirectoryObjectRequestBuilder { 179 bb := &DirectoryObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 180 bb.baseURL += "/" + id 181 return bb 182 } 183 184 // ApplicationOwnersCollectionRequest is request for DirectoryObject collection 185 type ApplicationOwnersCollectionRequest struct{ BaseRequest } 186 187 // Paging perfoms paging operation for DirectoryObject collection 188 func (r *ApplicationOwnersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]DirectoryObject, error) { 189 req, err := r.NewJSONRequest(method, path, obj) 190 if err != nil { 191 return nil, err 192 } 193 if ctx != nil { 194 req = req.WithContext(ctx) 195 } 196 res, err := r.client.Do(req) 197 if err != nil { 198 return nil, err 199 } 200 var values []DirectoryObject 201 for { 202 if res.StatusCode != http.StatusOK { 203 b, _ := ioutil.ReadAll(res.Body) 204 res.Body.Close() 205 errRes := &ErrorResponse{Response: res} 206 err := jsonx.Unmarshal(b, errRes) 207 if err != nil { 208 return nil, fmt.Errorf("%s: %s", res.Status, string(b)) 209 } 210 return nil, errRes 211 } 212 var ( 213 paging Paging 214 value []DirectoryObject 215 ) 216 err := jsonx.NewDecoder(res.Body).Decode(&paging) 217 res.Body.Close() 218 if err != nil { 219 return nil, err 220 } 221 err = jsonx.Unmarshal(paging.Value, &value) 222 if err != nil { 223 return nil, err 224 } 225 values = append(values, value...) 226 if n >= 0 { 227 n-- 228 } 229 if n == 0 || len(paging.NextLink) == 0 { 230 return values, nil 231 } 232 req, err = http.NewRequest("GET", paging.NextLink, nil) 233 if ctx != nil { 234 req = req.WithContext(ctx) 235 } 236 res, err = r.client.Do(req) 237 if err != nil { 238 return nil, err 239 } 240 } 241 } 242 243 // GetN performs GET request for DirectoryObject collection, max N pages 244 func (r *ApplicationOwnersCollectionRequest) GetN(ctx context.Context, n int) ([]DirectoryObject, error) { 245 var query string 246 if r.query != nil { 247 query = "?" + r.query.Encode() 248 } 249 return r.Paging(ctx, "GET", query, nil, n) 250 } 251 252 // Get performs GET request for DirectoryObject collection 253 func (r *ApplicationOwnersCollectionRequest) Get(ctx context.Context) ([]DirectoryObject, error) { 254 return r.GetN(ctx, 0) 255 } 256 257 // Add performs POST request for DirectoryObject collection 258 func (r *ApplicationOwnersCollectionRequest) Add(ctx context.Context, reqObj *DirectoryObject) (resObj *DirectoryObject, err error) { 259 err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) 260 return 261 } 262 263 // Policies returns request builder for DirectoryObject collection 264 func (b *ApplicationRequestBuilder) Policies() *ApplicationPoliciesCollectionRequestBuilder { 265 bb := &ApplicationPoliciesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 266 bb.baseURL += "/policies" 267 return bb 268 } 269 270 // ApplicationPoliciesCollectionRequestBuilder is request builder for DirectoryObject collection 271 type ApplicationPoliciesCollectionRequestBuilder struct{ BaseRequestBuilder } 272 273 // Request returns request for DirectoryObject collection 274 func (b *ApplicationPoliciesCollectionRequestBuilder) Request() *ApplicationPoliciesCollectionRequest { 275 return &ApplicationPoliciesCollectionRequest{ 276 BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, 277 } 278 } 279 280 // ID returns request builder for DirectoryObject item 281 func (b *ApplicationPoliciesCollectionRequestBuilder) ID(id string) *DirectoryObjectRequestBuilder { 282 bb := &DirectoryObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 283 bb.baseURL += "/" + id 284 return bb 285 } 286 287 // ApplicationPoliciesCollectionRequest is request for DirectoryObject collection 288 type ApplicationPoliciesCollectionRequest struct{ BaseRequest } 289 290 // Paging perfoms paging operation for DirectoryObject collection 291 func (r *ApplicationPoliciesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]DirectoryObject, error) { 292 req, err := r.NewJSONRequest(method, path, obj) 293 if err != nil { 294 return nil, err 295 } 296 if ctx != nil { 297 req = req.WithContext(ctx) 298 } 299 res, err := r.client.Do(req) 300 if err != nil { 301 return nil, err 302 } 303 var values []DirectoryObject 304 for { 305 if res.StatusCode != http.StatusOK { 306 b, _ := ioutil.ReadAll(res.Body) 307 res.Body.Close() 308 errRes := &ErrorResponse{Response: res} 309 err := jsonx.Unmarshal(b, errRes) 310 if err != nil { 311 return nil, fmt.Errorf("%s: %s", res.Status, string(b)) 312 } 313 return nil, errRes 314 } 315 var ( 316 paging Paging 317 value []DirectoryObject 318 ) 319 err := jsonx.NewDecoder(res.Body).Decode(&paging) 320 res.Body.Close() 321 if err != nil { 322 return nil, err 323 } 324 err = jsonx.Unmarshal(paging.Value, &value) 325 if err != nil { 326 return nil, err 327 } 328 values = append(values, value...) 329 if n >= 0 { 330 n-- 331 } 332 if n == 0 || len(paging.NextLink) == 0 { 333 return values, nil 334 } 335 req, err = http.NewRequest("GET", paging.NextLink, nil) 336 if ctx != nil { 337 req = req.WithContext(ctx) 338 } 339 res, err = r.client.Do(req) 340 if err != nil { 341 return nil, err 342 } 343 } 344 } 345 346 // GetN performs GET request for DirectoryObject collection, max N pages 347 func (r *ApplicationPoliciesCollectionRequest) GetN(ctx context.Context, n int) ([]DirectoryObject, error) { 348 var query string 349 if r.query != nil { 350 query = "?" + r.query.Encode() 351 } 352 return r.Paging(ctx, "GET", query, nil, n) 353 } 354 355 // Get performs GET request for DirectoryObject collection 356 func (r *ApplicationPoliciesCollectionRequest) Get(ctx context.Context) ([]DirectoryObject, error) { 357 return r.GetN(ctx, 0) 358 } 359 360 // Add performs POST request for DirectoryObject collection 361 func (r *ApplicationPoliciesCollectionRequest) Add(ctx context.Context, reqObj *DirectoryObject) (resObj *DirectoryObject, err error) { 362 err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) 363 return 364 } 365 366 // Synchronization is navigation property 367 func (b *ApplicationRequestBuilder) Synchronization() *SynchronizationRequestBuilder { 368 bb := &SynchronizationRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} 369 bb.baseURL += "/synchronization" 370 return bb 371 }