From de36c450f132835f48f21239ebff07963632aa3a Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Thu, 1 Sep 2022 09:09:28 +0000 Subject: [PATCH] Merge pull request #53 from rhafer/me-expand Add $expand for memberOf to /me --- README.md | 2 +- api/openapi.yaml | 16 ++++++++++++++++ api_me_user.go | 28 +++++++++++++++++++--------- docs/MeUserApi.md | 25 +++++++++++++++---------- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e7f8773..fd0024d 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Class | Method | HTTP request | Description *MeDriveRootApi* | [**HomeGetRoot**](docs/MeDriveRootApi.md#homegetroot) | **Get** /me/drive/root | Get root from personal space *MeDriveRootChildrenApi* | [**HomeGetChildren**](docs/MeDriveRootChildrenApi.md#homegetchildren) | **Get** /me/drive/root/children | Get children from drive *MeDrivesApi* | [**ListMyDrives**](docs/MeDrivesApi.md#listmydrives) | **Get** /me/drives | Get drives from me -*MeUserApi* | [**MeGet**](docs/MeUserApi.md#meget) | **Get** /me | +*MeUserApi* | [**GetOwnUser**](docs/MeUserApi.md#getownuser) | **Get** /me | Get current user *UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **Delete** /users/{user-id} | Delete entity from users *UserApi* | [**GetUser**](docs/UserApi.md#getuser) | **Get** /users/{user-id} | Get entity from users by key *UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **Patch** /users/{user-id} | Update entity in users diff --git a/api/openapi.yaml b/api/openapi.yaml index 0d3e640..2ce560b 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -13,6 +13,21 @@ security: paths: /me: get: + operationId: GetOwnUser + parameters: + - description: Expand related entities + explode: false + in: query + name: $expand + required: false + schema: + items: + enum: + - memberOf + type: string + type: array + uniqueItems: true + style: form responses: "200": content: @@ -26,6 +41,7 @@ paths: schema: $ref: '#/components/schemas/odata.error' description: error + summary: Get current user tags: - me.user x-ms-docs-operation-type: operation diff --git a/api_me_user.go b/api_me_user.go index a137fa5..61e058a 100644 --- a/api_me_user.go +++ b/api_me_user.go @@ -22,23 +22,30 @@ import ( // MeUserApiService MeUserApi service type MeUserApiService service -type ApiMeGetRequest struct { +type ApiGetOwnUserRequest struct { ctx context.Context ApiService *MeUserApiService + expand *[]string } -func (r ApiMeGetRequest) Execute() (*User, *http.Response, error) { - return r.ApiService.MeGetExecute(r) +// Expand related entities +func (r ApiGetOwnUserRequest) Expand(expand []string) ApiGetOwnUserRequest { + r.expand = &expand + return r +} + +func (r ApiGetOwnUserRequest) Execute() (*User, *http.Response, error) { + return r.ApiService.GetOwnUserExecute(r) } /* -MeGet Method for MeGet +GetOwnUser Get current user @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiMeGetRequest + @return ApiGetOwnUserRequest */ -func (a *MeUserApiService) MeGet(ctx context.Context) ApiMeGetRequest { - return ApiMeGetRequest{ +func (a *MeUserApiService) GetOwnUser(ctx context.Context) ApiGetOwnUserRequest { + return ApiGetOwnUserRequest{ ApiService: a, ctx: ctx, } @@ -46,7 +53,7 @@ func (a *MeUserApiService) MeGet(ctx context.Context) ApiMeGetRequest { // Execute executes the request // @return User -func (a *MeUserApiService) MeGetExecute(r ApiMeGetRequest) (*User, *http.Response, error) { +func (a *MeUserApiService) GetOwnUserExecute(r ApiGetOwnUserRequest) (*User, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} @@ -54,7 +61,7 @@ func (a *MeUserApiService) MeGetExecute(r ApiMeGetRequest) (*User, *http.Respons localVarReturnValue *User ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MeUserApiService.MeGet") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MeUserApiService.GetOwnUser") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } @@ -65,6 +72,9 @@ func (a *MeUserApiService) MeGetExecute(r ApiMeGetRequest) (*User, *http.Respons localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.expand != nil { + localVarQueryParams.Add("$expand", parameterToString(*r.expand, "csv")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} diff --git a/docs/MeUserApi.md b/docs/MeUserApi.md index 01cd675..aadf0e4 100644 --- a/docs/MeUserApi.md +++ b/docs/MeUserApi.md @@ -4,15 +4,15 @@ All URIs are relative to *https://ocis.ocis-traefik.latest.owncloud.works* Method | HTTP request | Description ------------- | ------------- | ------------- -[**MeGet**](MeUserApi.md#MeGet) | **Get** /me | +[**GetOwnUser**](MeUserApi.md#GetOwnUser) | **Get** /me | Get current user -## MeGet - -> User MeGet(ctx).Execute() +## GetOwnUser +> User GetOwnUser(ctx).Expand(expand).Execute() +Get current user ### Example @@ -27,27 +27,32 @@ import ( ) func main() { + expand := []string{"Expand_example"} // []string | Expand related entities (optional) configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.MeUserApi.MeGet(context.Background()).Execute() + resp, r, err := apiClient.MeUserApi.GetOwnUser(context.Background()).Expand(expand).Execute() if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `MeUserApi.MeGet``: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `MeUserApi.GetOwnUser``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } - // response from `MeGet`: User - fmt.Fprintf(os.Stdout, "Response from `MeUserApi.MeGet`: %v\n", resp) + // response from `GetOwnUser`: User + fmt.Fprintf(os.Stdout, "Response from `MeUserApi.GetOwnUser`: %v\n", resp) } ``` ### Path Parameters -This endpoint does not need any parameter. + ### Other Parameters -Other parameters are passed through a pointer to a apiMeGetRequest struct via the builder pattern +Other parameters are passed through a pointer to a apiGetOwnUserRequest struct via the builder pattern + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **expand** | **[]string** | Expand related entities | ### Return type