/* Libre Graph API Libre Graph is a free API for cloud collaboration inspired by the MS Graph API. API version: v1.0.4 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package libregraph import ( "bytes" "context" "io" "net/http" "net/url" ) // MeChangepasswordApiService MeChangepasswordApi service type MeChangepasswordApiService service type ApiChangeOwnPasswordRequest struct { ctx context.Context ApiService *MeChangepasswordApiService passwordChange *PasswordChange } // Password change request func (r ApiChangeOwnPasswordRequest) PasswordChange(passwordChange PasswordChange) ApiChangeOwnPasswordRequest { r.passwordChange = &passwordChange return r } func (r ApiChangeOwnPasswordRequest) Execute() (*http.Response, error) { return r.ApiService.ChangeOwnPasswordExecute(r) } /* ChangeOwnPassword Chanage your own password @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiChangeOwnPasswordRequest */ func (a *MeChangepasswordApiService) ChangeOwnPassword(ctx context.Context) ApiChangeOwnPasswordRequest { return ApiChangeOwnPasswordRequest{ ApiService: a, ctx: ctx, } } // Execute executes the request func (a *MeChangepasswordApiService) ChangeOwnPasswordExecute(r ApiChangeOwnPasswordRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MeChangepasswordApiService.ChangeOwnPassword") if err != nil { return nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/v1.0/me/changePassword" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if r.passwordChange == nil { return nil, reportError("passwordChange is required and must be specified") } // to determine the Content-Type header localVarHTTPContentTypes := []string{"application/json"} // set Content-Type header localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) if localVarHTTPContentType != "" { localVarHeaderParams["Content-Type"] = localVarHTTPContentType } // to determine the Accept header localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params localVarPostBody = r.passwordChange req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return nil, err } localVarHTTPResponse, err := a.client.callAPI(req) if err != nil || localVarHTTPResponse == nil { return localVarHTTPResponse, err } localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { newErr := &GenericOpenAPIError{ body: localVarBody, error: localVarHTTPResponse.Status, } var v OdataError err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { newErr.error = err.Error() return localVarHTTPResponse, newErr } newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) newErr.model = v return localVarHTTPResponse, newErr } return localVarHTTPResponse, nil }