diff options
Diffstat (limited to 'vendor/github.com/yaegashi/msgraph.go/beta/EducationRootRequest.go')
-rw-r--r-- | vendor/github.com/yaegashi/msgraph.go/beta/EducationRootRequest.go | 428 |
1 files changed, 428 insertions, 0 deletions
diff --git a/vendor/github.com/yaegashi/msgraph.go/beta/EducationRootRequest.go b/vendor/github.com/yaegashi/msgraph.go/beta/EducationRootRequest.go new file mode 100644 index 00000000..60f61d21 --- /dev/null +++ b/vendor/github.com/yaegashi/msgraph.go/beta/EducationRootRequest.go @@ -0,0 +1,428 @@ +// Code generated by msgraph-generate.go DO NOT EDIT. + +package msgraph + +import ( + "context" + "fmt" + "io/ioutil" + "net/http" + + "github.com/yaegashi/msgraph.go/jsonx" +) + +// EducationRootRequestBuilder is request builder for EducationRoot +type EducationRootRequestBuilder struct{ BaseRequestBuilder } + +// Request returns EducationRootRequest +func (b *EducationRootRequestBuilder) Request() *EducationRootRequest { + return &EducationRootRequest{ + BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, + } +} + +// EducationRootRequest is request for EducationRoot +type EducationRootRequest struct{ BaseRequest } + +// Get performs GET request for EducationRoot +func (r *EducationRootRequest) Get(ctx context.Context) (resObj *EducationRoot, err error) { + var query string + if r.query != nil { + query = "?" + r.query.Encode() + } + err = r.JSONRequest(ctx, "GET", query, nil, &resObj) + return +} + +// Update performs PATCH request for EducationRoot +func (r *EducationRootRequest) Update(ctx context.Context, reqObj *EducationRoot) error { + return r.JSONRequest(ctx, "PATCH", "", reqObj, nil) +} + +// Delete performs DELETE request for EducationRoot +func (r *EducationRootRequest) Delete(ctx context.Context) error { + return r.JSONRequest(ctx, "DELETE", "", nil, nil) +} + +// Classes returns request builder for EducationClass collection +func (b *EducationRootRequestBuilder) Classes() *EducationRootClassesCollectionRequestBuilder { + bb := &EducationRootClassesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/classes" + return bb +} + +// EducationRootClassesCollectionRequestBuilder is request builder for EducationClass collection +type EducationRootClassesCollectionRequestBuilder struct{ BaseRequestBuilder } + +// Request returns request for EducationClass collection +func (b *EducationRootClassesCollectionRequestBuilder) Request() *EducationRootClassesCollectionRequest { + return &EducationRootClassesCollectionRequest{ + BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, + } +} + +// ID returns request builder for EducationClass item +func (b *EducationRootClassesCollectionRequestBuilder) ID(id string) *EducationClassRequestBuilder { + bb := &EducationClassRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/" + id + return bb +} + +// EducationRootClassesCollectionRequest is request for EducationClass collection +type EducationRootClassesCollectionRequest struct{ BaseRequest } + +// Paging perfoms paging operation for EducationClass collection +func (r *EducationRootClassesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]EducationClass, error) { + req, err := r.NewJSONRequest(method, path, obj) + if err != nil { + return nil, err + } + if ctx != nil { + req = req.WithContext(ctx) + } + res, err := r.client.Do(req) + if err != nil { + return nil, err + } + var values []EducationClass + for { + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + b, _ := ioutil.ReadAll(res.Body) + errRes := &ErrorResponse{Response: res} + err := jsonx.Unmarshal(b, errRes) + if err != nil { + return nil, fmt.Errorf("%s: %s", res.Status, string(b)) + } + return nil, errRes + } + var ( + paging Paging + value []EducationClass + ) + err := jsonx.NewDecoder(res.Body).Decode(&paging) + if err != nil { + return nil, err + } + err = jsonx.Unmarshal(paging.Value, &value) + if err != nil { + return nil, err + } + values = append(values, value...) + if len(paging.NextLink) == 0 { + return values, nil + } + req, err = http.NewRequest("GET", paging.NextLink, nil) + if ctx != nil { + req = req.WithContext(ctx) + } + res, err = r.client.Do(req) + if err != nil { + return nil, err + } + } +} + +// Get performs GET request for EducationClass collection +func (r *EducationRootClassesCollectionRequest) Get(ctx context.Context) ([]EducationClass, error) { + var query string + if r.query != nil { + query = "?" + r.query.Encode() + } + return r.Paging(ctx, "GET", query, nil) +} + +// Add performs POST request for EducationClass collection +func (r *EducationRootClassesCollectionRequest) Add(ctx context.Context, reqObj *EducationClass) (resObj *EducationClass, err error) { + err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) + return +} + +// Me is navigation property +func (b *EducationRootRequestBuilder) Me() *EducationUserRequestBuilder { + bb := &EducationUserRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/me" + return bb +} + +// Schools returns request builder for EducationSchool collection +func (b *EducationRootRequestBuilder) Schools() *EducationRootSchoolsCollectionRequestBuilder { + bb := &EducationRootSchoolsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/schools" + return bb +} + +// EducationRootSchoolsCollectionRequestBuilder is request builder for EducationSchool collection +type EducationRootSchoolsCollectionRequestBuilder struct{ BaseRequestBuilder } + +// Request returns request for EducationSchool collection +func (b *EducationRootSchoolsCollectionRequestBuilder) Request() *EducationRootSchoolsCollectionRequest { + return &EducationRootSchoolsCollectionRequest{ + BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, + } +} + +// ID returns request builder for EducationSchool item +func (b *EducationRootSchoolsCollectionRequestBuilder) ID(id string) *EducationSchoolRequestBuilder { + bb := &EducationSchoolRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/" + id + return bb +} + +// EducationRootSchoolsCollectionRequest is request for EducationSchool collection +type EducationRootSchoolsCollectionRequest struct{ BaseRequest } + +// Paging perfoms paging operation for EducationSchool collection +func (r *EducationRootSchoolsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]EducationSchool, error) { + req, err := r.NewJSONRequest(method, path, obj) + if err != nil { + return nil, err + } + if ctx != nil { + req = req.WithContext(ctx) + } + res, err := r.client.Do(req) + if err != nil { + return nil, err + } + var values []EducationSchool + for { + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + b, _ := ioutil.ReadAll(res.Body) + errRes := &ErrorResponse{Response: res} + err := jsonx.Unmarshal(b, errRes) + if err != nil { + return nil, fmt.Errorf("%s: %s", res.Status, string(b)) + } + return nil, errRes + } + var ( + paging Paging + value []EducationSchool + ) + err := jsonx.NewDecoder(res.Body).Decode(&paging) + if err != nil { + return nil, err + } + err = jsonx.Unmarshal(paging.Value, &value) + if err != nil { + return nil, err + } + values = append(values, value...) + if len(paging.NextLink) == 0 { + return values, nil + } + req, err = http.NewRequest("GET", paging.NextLink, nil) + if ctx != nil { + req = req.WithContext(ctx) + } + res, err = r.client.Do(req) + if err != nil { + return nil, err + } + } +} + +// Get performs GET request for EducationSchool collection +func (r *EducationRootSchoolsCollectionRequest) Get(ctx context.Context) ([]EducationSchool, error) { + var query string + if r.query != nil { + query = "?" + r.query.Encode() + } + return r.Paging(ctx, "GET", query, nil) +} + +// Add performs POST request for EducationSchool collection +func (r *EducationRootSchoolsCollectionRequest) Add(ctx context.Context, reqObj *EducationSchool) (resObj *EducationSchool, err error) { + err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) + return +} + +// SynchronizationProfiles returns request builder for EducationSynchronizationProfile collection +func (b *EducationRootRequestBuilder) SynchronizationProfiles() *EducationRootSynchronizationProfilesCollectionRequestBuilder { + bb := &EducationRootSynchronizationProfilesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/synchronizationProfiles" + return bb +} + +// EducationRootSynchronizationProfilesCollectionRequestBuilder is request builder for EducationSynchronizationProfile collection +type EducationRootSynchronizationProfilesCollectionRequestBuilder struct{ BaseRequestBuilder } + +// Request returns request for EducationSynchronizationProfile collection +func (b *EducationRootSynchronizationProfilesCollectionRequestBuilder) Request() *EducationRootSynchronizationProfilesCollectionRequest { + return &EducationRootSynchronizationProfilesCollectionRequest{ + BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, + } +} + +// ID returns request builder for EducationSynchronizationProfile item +func (b *EducationRootSynchronizationProfilesCollectionRequestBuilder) ID(id string) *EducationSynchronizationProfileRequestBuilder { + bb := &EducationSynchronizationProfileRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/" + id + return bb +} + +// EducationRootSynchronizationProfilesCollectionRequest is request for EducationSynchronizationProfile collection +type EducationRootSynchronizationProfilesCollectionRequest struct{ BaseRequest } + +// Paging perfoms paging operation for EducationSynchronizationProfile collection +func (r *EducationRootSynchronizationProfilesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]EducationSynchronizationProfile, error) { + req, err := r.NewJSONRequest(method, path, obj) + if err != nil { + return nil, err + } + if ctx != nil { + req = req.WithContext(ctx) + } + res, err := r.client.Do(req) + if err != nil { + return nil, err + } + var values []EducationSynchronizationProfile + for { + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + b, _ := ioutil.ReadAll(res.Body) + errRes := &ErrorResponse{Response: res} + err := jsonx.Unmarshal(b, errRes) + if err != nil { + return nil, fmt.Errorf("%s: %s", res.Status, string(b)) + } + return nil, errRes + } + var ( + paging Paging + value []EducationSynchronizationProfile + ) + err := jsonx.NewDecoder(res.Body).Decode(&paging) + if err != nil { + return nil, err + } + err = jsonx.Unmarshal(paging.Value, &value) + if err != nil { + return nil, err + } + values = append(values, value...) + if len(paging.NextLink) == 0 { + return values, nil + } + req, err = http.NewRequest("GET", paging.NextLink, nil) + if ctx != nil { + req = req.WithContext(ctx) + } + res, err = r.client.Do(req) + if err != nil { + return nil, err + } + } +} + +// Get performs GET request for EducationSynchronizationProfile collection +func (r *EducationRootSynchronizationProfilesCollectionRequest) Get(ctx context.Context) ([]EducationSynchronizationProfile, error) { + var query string + if r.query != nil { + query = "?" + r.query.Encode() + } + return r.Paging(ctx, "GET", query, nil) +} + +// Add performs POST request for EducationSynchronizationProfile collection +func (r *EducationRootSynchronizationProfilesCollectionRequest) Add(ctx context.Context, reqObj *EducationSynchronizationProfile) (resObj *EducationSynchronizationProfile, err error) { + err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) + return +} + +// Users returns request builder for EducationUser collection +func (b *EducationRootRequestBuilder) Users() *EducationRootUsersCollectionRequestBuilder { + bb := &EducationRootUsersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/users" + return bb +} + +// EducationRootUsersCollectionRequestBuilder is request builder for EducationUser collection +type EducationRootUsersCollectionRequestBuilder struct{ BaseRequestBuilder } + +// Request returns request for EducationUser collection +func (b *EducationRootUsersCollectionRequestBuilder) Request() *EducationRootUsersCollectionRequest { + return &EducationRootUsersCollectionRequest{ + BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client}, + } +} + +// ID returns request builder for EducationUser item +func (b *EducationRootUsersCollectionRequestBuilder) ID(id string) *EducationUserRequestBuilder { + bb := &EducationUserRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder} + bb.baseURL += "/" + id + return bb +} + +// EducationRootUsersCollectionRequest is request for EducationUser collection +type EducationRootUsersCollectionRequest struct{ BaseRequest } + +// Paging perfoms paging operation for EducationUser collection +func (r *EducationRootUsersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]EducationUser, error) { + req, err := r.NewJSONRequest(method, path, obj) + if err != nil { + return nil, err + } + if ctx != nil { + req = req.WithContext(ctx) + } + res, err := r.client.Do(req) + if err != nil { + return nil, err + } + var values []EducationUser + for { + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + b, _ := ioutil.ReadAll(res.Body) + errRes := &ErrorResponse{Response: res} + err := jsonx.Unmarshal(b, errRes) + if err != nil { + return nil, fmt.Errorf("%s: %s", res.Status, string(b)) + } + return nil, errRes + } + var ( + paging Paging + value []EducationUser + ) + err := jsonx.NewDecoder(res.Body).Decode(&paging) + if err != nil { + return nil, err + } + err = jsonx.Unmarshal(paging.Value, &value) + if err != nil { + return nil, err + } + values = append(values, value...) + if len(paging.NextLink) == 0 { + return values, nil + } + req, err = http.NewRequest("GET", paging.NextLink, nil) + if ctx != nil { + req = req.WithContext(ctx) + } + res, err = r.client.Do(req) + if err != nil { + return nil, err + } + } +} + +// Get performs GET request for EducationUser collection +func (r *EducationRootUsersCollectionRequest) Get(ctx context.Context) ([]EducationUser, error) { + var query string + if r.query != nil { + query = "?" + r.query.Encode() + } + return r.Paging(ctx, "GET", query, nil) +} + +// Add performs POST request for EducationUser collection +func (r *EducationRootUsersCollectionRequest) Add(ctx context.Context, reqObj *EducationUser) (resObj *EducationUser, err error) { + err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj) + return +} |