From 722d73f9565d6fbcc0ca16cbc581ee63b5892382 Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Wed, 21 Aug 2024 09:39:44 -0400 Subject: [PATCH 01/33] WIP --- frontends/api/src/generated/v1/api.ts | 308 ++++++++++++++++++ .../api/src/hooks/learningResources/index.ts | 22 ++ .../Dialogs/AddToListDialog.tsx | 114 +++++-- .../Checkbox/CheckboxChoiceField.tsx | 12 +- learning_resources/views.py | 31 ++ 5 files changed, 456 insertions(+), 31 deletions(-) diff --git a/frontends/api/src/generated/v1/api.ts b/frontends/api/src/generated/v1/api.ts index 4b6095b59a..d6d05d5f61 100644 --- a/frontends/api/src/generated/v1/api.ts +++ b/frontends/api/src/generated/v1/api.ts @@ -15426,6 +15426,65 @@ export const LearningpathsApiAxiosParamCreator = function ( options: localVarRequestOptions, } }, + /** + * Set all relationships at once + * @param {number} learning_resource_id The learning resource id of the learning path + * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningpathsItemsSetAllPartialUpdate: async ( + learning_resource_id: number, + PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningpathsItemsSetAllPartialUpdate", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learningpaths/{learning_resource_id}/items/set_all/`.replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PATCH", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedLearningPathRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, /** * Get a paginated list of learning paths * @summary List @@ -15931,6 +15990,42 @@ export const LearningpathsApiFp = function (configuration?: Configuration) { configuration, )(axios, operationBasePath || basePath) }, + /** + * Set all relationships at once + * @param {number} learning_resource_id The learning resource id of the learning path + * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningpathsItemsSetAllPartialUpdate( + learning_resource_id: number, + PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningpathsItemsSetAllPartialUpdate( + learning_resource_id, + PatchedLearningPathRelationshipRequest, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningpathsApi.learningpathsItemsSetAllPartialUpdate" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, /** * Get a paginated list of learning paths * @summary List @@ -16223,6 +16318,24 @@ export const LearningpathsApiFactory = function ( ) .then((request) => request(axios, basePath)) }, + /** + * Set all relationships at once + * @param {LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningpathsItemsSetAllPartialUpdate( + requestParameters: LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningpathsItemsSetAllPartialUpdate( + requestParameters.learning_resource_id, + requestParameters.PatchedLearningPathRelationshipRequest, + options, + ) + .then((request) => request(axios, basePath)) + }, /** * Get a paginated list of learning paths * @summary List @@ -16448,6 +16561,27 @@ export interface LearningpathsApiLearningpathsItemsRetrieveRequest { readonly learning_resource_id: number } +/** + * Request parameters for learningpathsItemsSetAllPartialUpdate operation in LearningpathsApi. + * @export + * @interface LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest + */ +export interface LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest { + /** + * The learning resource id of the learning path + * @type {number} + * @memberof LearningpathsApiLearningpathsItemsSetAllPartialUpdate + */ + readonly learning_resource_id: number + + /** + * + * @type {PatchedLearningPathRelationshipRequest} + * @memberof LearningpathsApiLearningpathsItemsSetAllPartialUpdate + */ + readonly PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest +} + /** * Request parameters for learningpathsList operation in LearningpathsApi. * @export @@ -16761,6 +16895,26 @@ export class LearningpathsApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)) } + /** + * Set all relationships at once + * @param {LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningpathsApi + */ + public learningpathsItemsSetAllPartialUpdate( + requestParameters: LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningpathsApiFp(this.configuration) + .learningpathsItemsSetAllPartialUpdate( + requestParameters.learning_resource_id, + requestParameters.PatchedLearningPathRelationshipRequest, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + /** * Get a paginated list of learning paths * @summary List @@ -21372,6 +21526,65 @@ export const UserlistsApiAxiosParamCreator = function ( options: localVarRequestOptions, } }, + /** + * Set all relationships at once + * @param {number} userlist_id id of the parent user list + * @param {PatchedUserListRelationshipRequest} [PatchedUserListRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + userlistsItemsSetAllPartialUpdate: async ( + userlist_id: number, + PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'userlist_id' is not null or undefined + assertParamExists( + "userlistsItemsSetAllPartialUpdate", + "userlist_id", + userlist_id, + ) + const localVarPath = + `/api/v1/userlists/{userlist_id}/items/set_all/`.replace( + `{${"userlist_id"}}`, + encodeURIComponent(String(userlist_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PATCH", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedUserListRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, /** * Viewset for UserLists * @summary List @@ -21767,6 +21980,42 @@ export const UserlistsApiFp = function (configuration?: Configuration) { configuration, )(axios, operationBasePath || basePath) }, + /** + * Set all relationships at once + * @param {number} userlist_id id of the parent user list + * @param {PatchedUserListRelationshipRequest} [PatchedUserListRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async userlistsItemsSetAllPartialUpdate( + userlist_id: number, + PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.userlistsItemsSetAllPartialUpdate( + userlist_id, + PatchedUserListRelationshipRequest, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap["UserlistsApi.userlistsItemsSetAllPartialUpdate"]?.[ + index + ]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, /** * Viewset for UserLists * @summary List @@ -22000,6 +22249,24 @@ export const UserlistsApiFactory = function ( ) .then((request) => request(axios, basePath)) }, + /** + * Set all relationships at once + * @param {UserlistsApiUserlistsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + userlistsItemsSetAllPartialUpdate( + requestParameters: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .userlistsItemsSetAllPartialUpdate( + requestParameters.userlist_id, + requestParameters.PatchedUserListRelationshipRequest, + options, + ) + .then((request) => request(axios, basePath)) + }, /** * Viewset for UserLists * @summary List @@ -22203,6 +22470,27 @@ export interface UserlistsApiUserlistsItemsRetrieveRequest { readonly userlist_id: number } +/** + * Request parameters for userlistsItemsSetAllPartialUpdate operation in UserlistsApi. + * @export + * @interface UserlistsApiUserlistsItemsSetAllPartialUpdateRequest + */ +export interface UserlistsApiUserlistsItemsSetAllPartialUpdateRequest { + /** + * id of the parent user list + * @type {number} + * @memberof UserlistsApiUserlistsItemsSetAllPartialUpdate + */ + readonly userlist_id: number + + /** + * + * @type {PatchedUserListRelationshipRequest} + * @memberof UserlistsApiUserlistsItemsSetAllPartialUpdate + */ + readonly PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest +} + /** * Request parameters for userlistsList operation in UserlistsApi. * @export @@ -22407,6 +22695,26 @@ export class UserlistsApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)) } + /** + * Set all relationships at once + * @param {UserlistsApiUserlistsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserlistsApi + */ + public userlistsItemsSetAllPartialUpdate( + requestParameters: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return UserlistsApiFp(this.configuration) + .userlistsItemsSetAllPartialUpdate( + requestParameters.userlist_id, + requestParameters.PatchedUserListRelationshipRequest, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + /** * Viewset for UserLists * @summary List diff --git a/frontends/api/src/hooks/learningResources/index.ts b/frontends/api/src/hooks/learningResources/index.ts index e2deba4a0c..4b19e60178 100644 --- a/frontends/api/src/hooks/learningResources/index.ts +++ b/frontends/api/src/hooks/learningResources/index.ts @@ -28,6 +28,7 @@ import type { PlatformsApiPlatformsListRequest, FeaturedApiFeaturedListRequest as FeaturedListParams, PaginatedLearningResourceList, + UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, } from "../../generated/v1" import learningResources, { invalidateResourceQueries, @@ -319,6 +320,26 @@ const useUserListRelationshipCreate = () => { }) } +const useUserListSetAllRelationships = () => { + const queryClient = useQueryClient() + return useMutation({ + mutationFn: ( + params: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, + ) => userListsApi.userlistsItemsSetAllPartialUpdate(params), + // userListsApi.userlistsItemsCreate({ + // userlist_id: params.parent, + // UserListRelationshipRequest: params, + // }), + onSuccess: (response, _vars) => { + queryClient.setQueriesData( + learningResources.featured({}).queryKey, + (old) => updateListParentsOnAdd(response.data, old), + ) + }, + onSettled: (_response, _err, vars) => {}, + }) +} + const useUserListRelationshipDestroy = () => { const queryClient = useQueryClient() return useMutation({ @@ -462,6 +483,7 @@ export { useUserListRelationshipMove, useUserListRelationshipCreate, useUserListRelationshipDestroy, + useUserListSetAllRelationships, useInfiniteUserListItems, useOfferorsList, useListItemMove, diff --git a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx index f52c8cdffe..73c246bdcd 100644 --- a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx +++ b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react" +import React, { useId, useState } from "react" import { Dialog, Chip, @@ -10,6 +10,8 @@ import { LoadingSpinner, Typography, styled, + CheckboxChoiceField, + Button, } from "ol-components" import { RiLockLine, RiLockUnlockLine, RiAddLine } from "@remixicon/react" @@ -30,9 +32,11 @@ import { useUserListList, useUserListRelationshipCreate, useUserListRelationshipDestroy, + useUserListSetAllRelationships, } from "api/hooks/learningResources" import { manageListDialogs } from "@/page-components/ManageListDialogs/ManageListDialogs" import { ListType } from "api/constants" +import { useFormik } from "formik" const useLearningPathRequestRecord = () => { const [pending, setPending] = useState>( @@ -209,12 +213,60 @@ const AddToListDialogInner: React.FC = ({ isReady, }) => { const modal = NiceModal.useModal() + const setUserListRelationships = useUserListSetAllRelationships() let dialogTitle = "Add to list" if (listType === ListType.LearningPath) { dialogTitle = "Add to Learning List" } else if (listType === ListType.UserList) { dialogTitle = "Add to User List" } + const listChoices = lists.map((list) => ({ + value: list.id.toString(), + label: list.title, + })) + const learningPathValues = lists + .map((list) => + resource?.learning_path_parents?.some(({ parent }) => parent === list.id) + ? list.id.toString() + : null, + ) + .filter((value) => value !== null) + const userListValues = lists + .map((list) => + resource?.user_list_parents?.some(({ parent }) => parent === list.id) + ? list.id.toString() + : null, + ) + .filter((value) => value !== null) + const formId = useId() + const formik = useFormik({ + enableReinitialize: true, + validateOnChange: false, + validateOnBlur: false, + initialValues: { + learning_paths: learningPathValues, + user_lists: userListValues, + }, + onSubmit: () => {}, + }) + const save = async (values: { learning_paths: string[]; user_lists: string[] }) => { + if (formik.dirty) { + console.log(values) + if (listType === ListType.LearningPath) { + } + else if (listType === ListType.UserList) { + if (resource) { + const newParents = values.user_lists.map((id) => parseInt(id)) + const removedParents = listChoices.map((list) => list.value).filter((id) => !newParents.includes(parseInt(id))) + await setUserListRelationships.mutateAsync({ + child: resource.id, + add_parents: newParents, + remove_parents: removedParents + }) + } + } + } + return ( = ({ {...NiceModal.muiDialogV5(modal)} > {isReady ? ( - <> +
Adding {resource?.title} {listType === ListType.LearningPath ? ( - - - - manageListDialogs.upsertLearningPath()} - > - - - - - ) : null} {listType === ListType.UserList ? ( - - - - manageListDialogs.upsertUserList()} - > - - - - - ) : null} - +
+ + +
+
) : ( )} diff --git a/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx b/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx index 146438c660..452267863a 100644 --- a/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx +++ b/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx @@ -12,6 +12,7 @@ export type CheckboxChoiceFieldProps = { values?: string[] onChange?: CheckboxProps["onChange"] className?: string + vertical?: boolean } const Container = styled.div(({ theme }) => ({ @@ -23,6 +24,11 @@ const Container = styled.div(({ theme }) => ({ }, })) +const VerticalContainer = styled(Container)({ + gap: "18px", + flexDirection: "column", +}) + const Label = styled(FormLabel)(({ theme }) => ({ marginTop: "0", marginBottom: "16px", @@ -38,9 +44,11 @@ const CheckboxChoiceField: React.FC = ({ values, onChange, className, + vertical = false, }) => { const isChecked = (choice: CheckboxProps) => choice.value ? (values?.includes(choice.value) ?? false) : false + const _Container = vertical ? VerticalContainer : Container return ( = ({ className={className} > - + <_Container> {choices.map((choice) => { return ( = ({ /> ) })} - + ) } diff --git a/learning_resources/views.py b/learning_resources/views.py index 77d5d8b6f3..4b0b88d2be 100644 --- a/learning_resources/views.py +++ b/learning_resources/views.py @@ -15,6 +15,7 @@ from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_view from rest_framework import views, viewsets +from rest_framework.decorators import action from rest_framework.filters import OrderingFilter from rest_framework.generics import get_object_or_404 from rest_framework.pagination import LimitOffsetPagination @@ -418,6 +419,22 @@ def perform_destroy(self, instance): ).update(position=F("position") - 1) instance.delete() + @action(detail=False, methods=["patch"], name="Set all Learning Path Relationships") + def set_all(self, request, *args, **kwargs): + """ + Set all relationships at once + """ + child_id = request.data.get("child") + add_parents = request.data.get("add_parents", []) + remove_parents = request.data.get("remove_parents", []) + LearningResourceRelationship.objects.filter( + parent_id__in=remove_parents, child_id=child_id + ).delete() + for parent_id in add_parents: + LearningResourceRelationship.objects.create( + parent_id=parent_id, child_id=child_id + ) + @extend_schema_view( list=extend_schema(summary="List"), @@ -581,6 +598,20 @@ def perform_destroy(self, instance): position__gt=instance.position, ).update(position=F("position") - 1) + @action(detail=False, methods=["patch"], name="Set all User List Relationships") + def set_all(self, request, *args, **kwargs): + """ + Set all relationships at once + """ + child_id = kwargs.get("child") + add_parents = kwargs.get("add_parents", []) + remove_parents = kwargs.get("remove_parents", []) + UserListRelationship.objects.filter( + parent_id__in=remove_parents, child_id=child_id + ).delete() + for parent_id in add_parents: + UserListRelationship.objects.create(parent_id=parent_id, child_id=child_id) + @cache_page(60 * settings.RSS_FEED_CACHE_MINUTES) def podcast_rss_feed(request): # noqa: ARG001 From 55aad9f80960a5b3d47d15a0bad47e9180aba54a Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Fri, 23 Aug 2024 17:58:39 -0400 Subject: [PATCH 02/33] rework api endpoints and implement them --- frontends/api/src/generated/v1/api.ts | 2473 +++++++++++++---- .../api/src/hooks/learningResources/index.ts | 62 +- .../Dialogs/AddToListDialog.tsx | 338 +-- .../Checkbox/CheckboxChoiceField.tsx | 4 +- learning_resources/urls.py | 6 +- learning_resources/views.py | 115 +- 6 files changed, 2091 insertions(+), 907 deletions(-) diff --git a/frontends/api/src/generated/v1/api.ts b/frontends/api/src/generated/v1/api.ts index d6d05d5f61..4b141b946f 100644 --- a/frontends/api/src/generated/v1/api.ts +++ b/frontends/api/src/generated/v1/api.ts @@ -1998,6 +1998,38 @@ export interface LearningResourceRelationship { child: number } +/** + * CRUD serializer for LearningResourceRelationship + * @export + * @interface LearningResourceRelationshipRequest + */ +export interface LearningResourceRelationshipRequest { + /** + * + * @type {number} + * @memberof LearningResourceRelationshipRequest + */ + position?: number + /** + * + * @type {RelationTypeEnum} + * @memberof LearningResourceRelationshipRequest + */ + relation_type?: RelationTypeEnum + /** + * + * @type {number} + * @memberof LearningResourceRelationshipRequest + */ + parent: number + /** + * + * @type {number} + * @memberof LearningResourceRelationshipRequest + */ + child: number +} + /** * @type LearningResourceRequest * @export @@ -3300,6 +3332,38 @@ export interface PatchedLearningPathResourceRequest { completeness?: number } +/** + * CRUD serializer for LearningResourceRelationship + * @export + * @interface PatchedLearningResourceRelationshipRequest + */ +export interface PatchedLearningResourceRelationshipRequest { + /** + * + * @type {number} + * @memberof PatchedLearningResourceRelationshipRequest + */ + position?: number + /** + * + * @type {RelationTypeEnum} + * @memberof PatchedLearningResourceRelationshipRequest + */ + relation_type?: RelationTypeEnum + /** + * + * @type {number} + * @memberof PatchedLearningResourceRelationshipRequest + */ + parent?: number + /** + * + * @type {number} + * @memberof PatchedLearningResourceRelationshipRequest + */ + child?: number +} + /** * Serializer for UserListRelationship model * @export @@ -10706,22 +10770,38 @@ export const LearningResourcesApiAxiosParamCreator = function ( } }, /** - * Retrieve a single learning resource. - * @summary Retrieve - * @param {number} id A unique integer value identifying this learning resource. + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {number} learning_resource_id id of the parent learning resource + * @param {LearningResourceRelationshipRequest} LearningResourceRelationshipRequest + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningResourcesRetrieve: async ( - id: number, + learningResourcesRelationshipsCreate: async ( + learning_resource_id: number, + LearningResourceRelationshipRequest: LearningResourceRelationshipRequest, + learning_path_id?: Array, + userlist_id?: Array, options: RawAxiosRequestConfig = {}, ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("learningResourcesRetrieve", "id", id) - const localVarPath = `/api/v1/learning_resources/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsCreate", + "learning_resource_id", + learning_resource_id, ) + // verify required parameter 'LearningResourceRelationshipRequest' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsCreate", + "LearningResourceRelationshipRequest", + LearningResourceRelationshipRequest, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/`.replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) let baseOptions @@ -10730,13 +10810,23 @@ export const LearningResourcesApiAxiosParamCreator = function ( } const localVarRequestOptions = { - method: "GET", + method: "POST", ...baseOptions, ...options, } const localVarHeaderParameter = {} as any const localVarQueryParameter = {} as any + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + localVarHeaderParameter["Content-Type"] = "application/json" + setSearchParams(localVarUrlObj, localVarQueryParameter) let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {} @@ -10745,103 +10835,1025 @@ export const LearningResourcesApiAxiosParamCreator = function ( ...headersFromBaseOptions, ...options.headers, } + localVarRequestOptions.data = serializeDataIfNeeded( + LearningResourceRelationshipRequest, + localVarRequestOptions, + configuration, + ) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, } }, - } -} + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsDestroy: async ( + id: string, + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningResourcesRelationshipsDestroy", "id", id) + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsDestroy", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/{id}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } -/** - * LearningResourcesApi - functional programming interface - * @export - */ -export const LearningResourcesApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = - LearningResourcesApiAxiosParamCreator(configuration) - return { + const localVarRequestOptions = { + method: "DELETE", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, /** - * Show content files for a learning resource - * @summary Learning Resource Content File List + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths * @param {number} learning_resource_id id of the parent learning resource - * @param {Array} [content_feature_type] Multiple values may be separated by commas. - * @param {number} [limit] Number of results to return per page. - * @param {Array} [offered_by] The organization that offers a learning resource the content file belongs to * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education - * @param {number} [offset] The initial index from which to return the results. - * @param {Array} [platform] The platform on which learning resources the content file belongs to is offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube - * @param {Array} [resource_id] Multiple values may be separated by commas. - * @param {Array} [run_id] Multiple values may be separated by commas. + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async learningResourcesContentfilesList( + learningResourcesRelationshipsList: async ( learning_resource_id: number, - content_feature_type?: Array, - limit?: number, - offered_by?: Array, - offset?: number, - platform?: Array, - resource_id?: Array, - run_id?: Array, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.learningResourcesContentfilesList( - learning_resource_id, - content_feature_type, - limit, - offered_by, - offset, - platform, - resource_id, - run_id, - options, + learning_path_id?: Array, + userlist_id?: Array, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsList", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/`.replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap[ - "LearningResourcesApi.learningResourcesContentfilesList" - ]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "GET", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } }, /** - * Show content files for a learning resource - * @summary Learning Resource Content File Retrieve - * @param {number} id A unique integer value identifying this contentfile. + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async learningResourcesContentfilesRetrieve( - id: number, + learningResourcesRelationshipsPartialUpdate: async ( + id: string, learning_resource_id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.learningResourcesContentfilesRetrieve( - id, - learning_resource_id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningResourcesRelationshipsPartialUpdate", "id", id) + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsPartialUpdate", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/{id}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PATCH", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedLearningResourceRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsRetrieve: async ( + id: string, + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningResourcesRelationshipsRetrieve", "id", id) + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsRetrieve", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/{id}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "GET", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Set Learning Path relationships for a given Learning Resource + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate: + async ( + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/set_learning_path_relationships/`.replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PATCH", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedLearningResourceRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Set User List Relationships on a given Learning Resource. + * @summary Set User List Relationships + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate: async ( + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate", + "learning_resource_id", + learning_resource_id, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/set_user_list_relationships/`.replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PATCH", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedLearningResourceRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {LearningResourceRelationshipRequest} LearningResourceRelationshipRequest + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsUpdate: async ( + id: string, + learning_resource_id: number, + LearningResourceRelationshipRequest: LearningResourceRelationshipRequest, + learning_path_id?: Array, + userlist_id?: Array, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningResourcesRelationshipsUpdate", "id", id) + // verify required parameter 'learning_resource_id' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsUpdate", + "learning_resource_id", + learning_resource_id, + ) + // verify required parameter 'LearningResourceRelationshipRequest' is not null or undefined + assertParamExists( + "learningResourcesRelationshipsUpdate", + "LearningResourceRelationshipRequest", + LearningResourceRelationshipRequest, + ) + const localVarPath = + `/api/v1/learning_resources/{learning_resource_id}/relationships/{id}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "PUT", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + if (learning_path_id) { + localVarQueryParameter["learning_path_id"] = learning_path_id + } + + if (userlist_id) { + localVarQueryParameter["userlist_id"] = userlist_id + } + + localVarHeaderParameter["Content-Type"] = "application/json" + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + localVarRequestOptions.data = serializeDataIfNeeded( + LearningResourceRelationshipRequest, + localVarRequestOptions, + configuration, + ) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Retrieve a single learning resource. + * @summary Retrieve + * @param {number} id A unique integer value identifying this learning resource. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRetrieve: async ( + id: number, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningResourcesRetrieve", "id", id) + const localVarPath = `/api/v1/learning_resources/{id}/`.replace( + `{${"id"}}`, + encodeURIComponent(String(id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "GET", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + } +} + +/** + * LearningResourcesApi - functional programming interface + * @export + */ +export const LearningResourcesApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + LearningResourcesApiAxiosParamCreator(configuration) + return { + /** + * Show content files for a learning resource + * @summary Learning Resource Content File List + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [content_feature_type] Multiple values may be separated by commas. + * @param {number} [limit] Number of results to return per page. + * @param {Array} [offered_by] The organization that offers a learning resource the content file belongs to * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education + * @param {number} [offset] The initial index from which to return the results. + * @param {Array} [platform] The platform on which learning resources the content file belongs to is offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube + * @param {Array} [resource_id] Multiple values may be separated by commas. + * @param {Array} [run_id] Multiple values may be separated by commas. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesContentfilesList( + learning_resource_id: number, + content_feature_type?: Array, + limit?: number, + offered_by?: Array, + offset?: number, + platform?: Array, + resource_id?: Array, + run_id?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesContentfilesList( + learning_resource_id, + content_feature_type, + limit, + offered_by, + offset, + platform, + resource_id, + run_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesContentfilesList" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Show content files for a learning resource + * @summary Learning Resource Content File Retrieve + * @param {number} id A unique integer value identifying this contentfile. + * @param {number} learning_resource_id id of the parent learning resource + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesContentfilesRetrieve( + id: number, + learning_resource_id: number, + options?: RawAxiosRequestConfig, + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesContentfilesRetrieve( + id, + learning_resource_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesContentfilesRetrieve" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Get a list of related learning resources for a learning resource. + * @summary Nested Learning Resource List + * @param {number} learning_resource_id id of the parent learning resource + * @param {number} [limit] Number of results to return per page. + * @param {number} [offset] The initial index from which to return the results. + * @param {string} [sortby] Which field to use when ordering the results. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesItemsList( + learning_resource_id: number, + limit?: number, + offset?: number, + sortby?: string, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesItemsList( + learning_resource_id, + limit, + offset, + sortby, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap["LearningResourcesApi.learningResourcesItemsList"]?.[ + index + ]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Get a singe related learning resource for a learning resource. + * @summary Nested Learning Resource Retrieve + * @param {number} id A unique integer value identifying this learning resource relationship. + * @param {number} learning_resource_id id of the parent learning resource + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesItemsRetrieve( + id: number, + learning_resource_id: number, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesItemsRetrieve( + id, + learning_resource_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesItemsRetrieve" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Get a paginated list of learning resources. + * @summary List + * @param {boolean} [certification] + * @param {Array} [certification_type] The type of certification offered * `micromasters` - Micromasters Credential * `professional` - Professional Certificate * `completion` - Certificate of Completion * `none` - No Certificate + * @param {Array} [course_feature] Multiple values may be separated by commas. + * @param {Array} [department] The department that offers learning resources * `1` - Civil and Environmental Engineering * `2` - Mechanical Engineering * `3` - Materials Science and Engineering * `4` - Architecture * `5` - Chemistry * `6` - Electrical Engineering and Computer Science * `7` - Biology * `8` - Physics * `9` - Brain and Cognitive Sciences * `10` - Chemical Engineering * `11` - Urban Studies and Planning * `12` - Earth, Atmospheric, and Planetary Sciences * `14` - Economics * `15` - Management * `16` - Aeronautics and Astronautics * `17` - Political Science * `18` - Mathematics * `20` - Biological Engineering * `21A` - Anthropology * `21G` - Global Languages * `21H` - History * `21L` - Literature * `21M` - Music and Theater Arts * `22` - Nuclear Science and Engineering * `24` - Linguistics and Philosophy * `CC` - Concourse * `CMS-W` - Comparative Media Studies/Writing * `EC` - Edgerton Center * `ES` - Experimental Study Group * `ESD` - Engineering Systems Division * `HST` - Medical Engineering and Science * `IDS` - Data, Systems, and Society * `MAS` - Media Arts and Sciences * `PE` - Athletics, Physical Education and Recreation * `SP` - Special Programs * `STS` - Science, Technology, and Society * `WGS` - Women\'s and Gender Studies + * @param {boolean} [free] The course/program is offered for free + * @param {Array>} [learning_format] The learning format of course/program resources * `online` - Online * `hybrid` - Hybrid * `in_person` - In person + * @param {Array} [level] The academic level of the resources * `undergraduate` - Undergraduate * `graduate` - Graduate * `high_school` - High School * `noncredit` - Non-Credit * `advanced` - Advanced * `intermediate` - Intermediate * `introductory` - Introductory + * @param {number} [limit] Number of results to return per page. + * @param {Array} [offered_by] The organization that offers a learning resource * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education + * @param {number} [offset] The initial index from which to return the results. + * @param {Array} [platform] The platform on which learning resources are offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube + * @param {boolean} [professional] + * @param {Array} [readable_id] Multiple values may be separated by commas. + * @param {Array} [resource_category] The resource category of the learning resources * `course` - Course * `program` - Program * `learning_material` - Learning Material + * @param {Array} [resource_type] The type of learning resource * `course` - Course * `program` - Program * `learning_path` - Learning Path * `podcast` - Podcast * `podcast_episode` - Podcast Episode * `video` - Video * `video_playlist` - Video Playlist + * @param {LearningResourcesListSortbyEnum} [sortby] Sort By * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending + * @param {Array} [topic] Multiple values may be separated by commas. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesList( + certification?: boolean, + certification_type?: Array, + course_feature?: Array, + department?: Array, + free?: boolean, + learning_format?: Array>, + level?: Array, + limit?: number, + offered_by?: Array, + offset?: number, + platform?: Array, + professional?: boolean, + readable_id?: Array, + resource_category?: Array, + resource_type?: Array, + sortby?: LearningResourcesListSortbyEnum, + topic?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesList( + certification, + certification_type, + course_feature, + department, + free, + learning_format, + level, + limit, + offered_by, + offset, + platform, + professional, + readable_id, + resource_category, + resource_type, + sortby, + topic, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap["LearningResourcesApi.learningResourcesList"]?.[ + index + ]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {number} learning_resource_id id of the parent learning resource + * @param {LearningResourceRelationshipRequest} LearningResourceRelationshipRequest + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesRelationshipsCreate( + learning_resource_id: number, + LearningResourceRelationshipRequest: LearningResourceRelationshipRequest, + learning_path_id?: Array, + userlist_id?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesRelationshipsCreate( + learning_resource_id, + LearningResourceRelationshipRequest, + learning_path_id, + userlist_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsCreate" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesRelationshipsDestroy( + id: string, + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesRelationshipsDestroy( + id, + learning_resource_id, + learning_path_id, + userlist_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsDestroy" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesRelationshipsList( + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise> + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesRelationshipsList( + learning_resource_id, + learning_path_id, + userlist_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsList" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesRelationshipsPartialUpdate( + id: string, + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesRelationshipsPartialUpdate( + id, + learning_resource_id, + learning_path_id, + userlist_id, + PatchedLearningResourceRelationshipRequest, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsPartialUpdate" + ]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async learningResourcesRelationshipsRetrieve( + id: string, + learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.learningResourcesRelationshipsRetrieve( + id, + learning_resource_id, + learning_path_id, + userlist_id, + options, + ) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = operationServerMap[ - "LearningResourcesApi.learningResourcesContentfilesRetrieve" + "LearningResourcesApi.learningResourcesRelationshipsRetrieve" ]?.[index]?.url return (axios, basePath) => createRequestFunction( @@ -10852,40 +11864,39 @@ export const LearningResourcesApiFp = function (configuration?: Configuration) { )(axios, operationBasePath || basePath) }, /** - * Get a list of related learning resources for a learning resource. - * @summary Nested Learning Resource List + * Set Learning Path relationships for a given Learning Resource * @param {number} learning_resource_id id of the parent learning resource - * @param {number} [limit] Number of results to return per page. - * @param {number} [offset] The initial index from which to return the results. - * @param {string} [sortby] Which field to use when ordering the results. + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async learningResourcesItemsList( + async learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( learning_resource_id: number, - limit?: number, - offset?: number, - sortby?: string, + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, options?: RawAxiosRequestConfig, ): Promise< ( axios?: AxiosInstance, basePath?: string, - ) => AxiosPromise + ) => AxiosPromise > { const localVarAxiosArgs = - await localVarAxiosParamCreator.learningResourcesItemsList( + await localVarAxiosParamCreator.learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( learning_resource_id, - limit, - offset, - sortby, + learning_path_id, + userlist_id, + PatchedLearningResourceRelationshipRequest, options, ) const index = configuration?.serverIndex ?? 0 const operationBasePath = - operationServerMap["LearningResourcesApi.learningResourcesItemsList"]?.[ - index - ]?.url + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate" + ]?.[index]?.url return (axios, basePath) => createRequestFunction( localVarAxiosArgs, @@ -10895,16 +11906,20 @@ export const LearningResourcesApiFp = function (configuration?: Configuration) { )(axios, operationBasePath || basePath) }, /** - * Get a singe related learning resource for a learning resource. - * @summary Nested Learning Resource Retrieve - * @param {number} id A unique integer value identifying this learning resource relationship. + * Set User List Relationships on a given Learning Resource. + * @summary Set User List Relationships * @param {number} learning_resource_id id of the parent learning resource + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list + * @param {PatchedLearningResourceRelationshipRequest} [PatchedLearningResourceRelationshipRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async learningResourcesItemsRetrieve( - id: number, + async learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( learning_resource_id: number, + learning_path_id?: Array, + userlist_id?: Array, + PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest, options?: RawAxiosRequestConfig, ): Promise< ( @@ -10913,15 +11928,17 @@ export const LearningResourcesApiFp = function (configuration?: Configuration) { ) => AxiosPromise > { const localVarAxiosArgs = - await localVarAxiosParamCreator.learningResourcesItemsRetrieve( - id, + await localVarAxiosParamCreator.learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( learning_resource_id, + learning_path_id, + userlist_id, + PatchedLearningResourceRelationshipRequest, options, ) const index = configuration?.serverIndex ?? 0 const operationBasePath = operationServerMap[ - "LearningResourcesApi.learningResourcesItemsRetrieve" + "LearningResourcesApi.learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate" ]?.[index]?.url return (axios, basePath) => createRequestFunction( @@ -10932,79 +11949,42 @@ export const LearningResourcesApiFp = function (configuration?: Configuration) { )(axios, operationBasePath || basePath) }, /** - * Get a paginated list of learning resources. - * @summary List - * @param {boolean} [certification] - * @param {Array} [certification_type] The type of certification offered * `micromasters` - Micromasters Credential * `professional` - Professional Certificate * `completion` - Certificate of Completion * `none` - No Certificate - * @param {Array} [course_feature] Multiple values may be separated by commas. - * @param {Array} [department] The department that offers learning resources * `1` - Civil and Environmental Engineering * `2` - Mechanical Engineering * `3` - Materials Science and Engineering * `4` - Architecture * `5` - Chemistry * `6` - Electrical Engineering and Computer Science * `7` - Biology * `8` - Physics * `9` - Brain and Cognitive Sciences * `10` - Chemical Engineering * `11` - Urban Studies and Planning * `12` - Earth, Atmospheric, and Planetary Sciences * `14` - Economics * `15` - Management * `16` - Aeronautics and Astronautics * `17` - Political Science * `18` - Mathematics * `20` - Biological Engineering * `21A` - Anthropology * `21G` - Global Languages * `21H` - History * `21L` - Literature * `21M` - Music and Theater Arts * `22` - Nuclear Science and Engineering * `24` - Linguistics and Philosophy * `CC` - Concourse * `CMS-W` - Comparative Media Studies/Writing * `EC` - Edgerton Center * `ES` - Experimental Study Group * `ESD` - Engineering Systems Division * `HST` - Medical Engineering and Science * `IDS` - Data, Systems, and Society * `MAS` - Media Arts and Sciences * `PE` - Athletics, Physical Education and Recreation * `SP` - Special Programs * `STS` - Science, Technology, and Society * `WGS` - Women\'s and Gender Studies - * @param {boolean} [free] The course/program is offered for free - * @param {Array>} [learning_format] The learning format of course/program resources * `online` - Online * `hybrid` - Hybrid * `in_person` - In person - * @param {Array} [level] The academic level of the resources * `undergraduate` - Undergraduate * `graduate` - Graduate * `high_school` - High School * `noncredit` - Non-Credit * `advanced` - Advanced * `intermediate` - Intermediate * `introductory` - Introductory - * @param {number} [limit] Number of results to return per page. - * @param {Array} [offered_by] The organization that offers a learning resource * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education - * @param {number} [offset] The initial index from which to return the results. - * @param {Array} [platform] The platform on which learning resources are offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube - * @param {boolean} [professional] - * @param {Array} [readable_id] Multiple values may be separated by commas. - * @param {Array} [resource_category] The resource category of the learning resources * `course` - Course * `program` - Program * `learning_material` - Learning Material - * @param {Array} [resource_type] The type of learning resource * `course` - Course * `program` - Program * `learning_path` - Learning Path * `podcast` - Podcast * `podcast_episode` - Podcast Episode * `video` - Video * `video_playlist` - Video Playlist - * @param {LearningResourcesListSortbyEnum} [sortby] Sort By * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending - * @param {Array} [topic] Multiple values may be separated by commas. + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {string} id + * @param {number} learning_resource_id id of the parent learning resource + * @param {LearningResourceRelationshipRequest} LearningResourceRelationshipRequest + * @param {Array} [learning_path_id] id of the parent learning path + * @param {Array} [userlist_id] id of the parent user list * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async learningResourcesList( - certification?: boolean, - certification_type?: Array, - course_feature?: Array, - department?: Array, - free?: boolean, - learning_format?: Array>, - level?: Array, - limit?: number, - offered_by?: Array, - offset?: number, - platform?: Array, - professional?: boolean, - readable_id?: Array, - resource_category?: Array, - resource_type?: Array, - sortby?: LearningResourcesListSortbyEnum, - topic?: Array, + async learningResourcesRelationshipsUpdate( + id: string, + learning_resource_id: number, + LearningResourceRelationshipRequest: LearningResourceRelationshipRequest, + learning_path_id?: Array, + userlist_id?: Array, options?: RawAxiosRequestConfig, ): Promise< ( axios?: AxiosInstance, basePath?: string, - ) => AxiosPromise + ) => AxiosPromise > { const localVarAxiosArgs = - await localVarAxiosParamCreator.learningResourcesList( - certification, - certification_type, - course_feature, - department, - free, - learning_format, - level, - limit, - offered_by, - offset, - platform, - professional, - readable_id, - resource_category, - resource_type, - sortby, - topic, + await localVarAxiosParamCreator.learningResourcesRelationshipsUpdate( + id, + learning_resource_id, + LearningResourceRelationshipRequest, + learning_path_id, + userlist_id, options, ) const index = configuration?.serverIndex ?? 0 const operationBasePath = - operationServerMap["LearningResourcesApi.learningResourcesList"]?.[ - index - ]?.url + operationServerMap[ + "LearningResourcesApi.learningResourcesRelationshipsUpdate" + ]?.[index]?.url return (axios, basePath) => createRequestFunction( localVarAxiosArgs, @@ -11109,69 +12089,231 @@ export const LearningResourcesApiFactory = function ( * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningResourcesItemsList( - requestParameters: LearningResourcesApiLearningResourcesItemsListRequest, + learningResourcesItemsList( + requestParameters: LearningResourcesApiLearningResourcesItemsListRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesItemsList( + requestParameters.learning_resource_id, + requestParameters.limit, + requestParameters.offset, + requestParameters.sortby, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Get a singe related learning resource for a learning resource. + * @summary Nested Learning Resource Retrieve + * @param {LearningResourcesApiLearningResourcesItemsRetrieveRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesItemsRetrieve( + requestParameters: LearningResourcesApiLearningResourcesItemsRetrieveRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesItemsRetrieve( + requestParameters.id, + requestParameters.learning_resource_id, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Get a paginated list of learning resources. + * @summary List + * @param {LearningResourcesApiLearningResourcesListRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesList( + requestParameters: LearningResourcesApiLearningResourcesListRequest = {}, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesList( + requestParameters.certification, + requestParameters.certification_type, + requestParameters.course_feature, + requestParameters.department, + requestParameters.free, + requestParameters.learning_format, + requestParameters.level, + requestParameters.limit, + requestParameters.offered_by, + requestParameters.offset, + requestParameters.platform, + requestParameters.professional, + requestParameters.readable_id, + requestParameters.resource_category, + requestParameters.resource_type, + requestParameters.sortby, + requestParameters.topic, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsCreateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsCreate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsCreateRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesRelationshipsCreate( + requestParameters.learning_resource_id, + requestParameters.LearningResourceRelationshipRequest, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsDestroyRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsDestroy( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsDestroyRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesRelationshipsDestroy( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsListRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsList( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsListRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise> { + return localVarFp + .learningResourcesRelationshipsList( + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesRelationshipsPartialUpdate( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsRetrieve( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .learningResourcesRelationshipsRetrieve( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(axios, basePath)) + }, + /** + * Set Learning Path relationships for a given Learning Resource + * @param {LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest, options?: RawAxiosRequestConfig, - ): AxiosPromise { + ): AxiosPromise { return localVarFp - .learningResourcesItemsList( + .learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( requestParameters.learning_resource_id, - requestParameters.limit, - requestParameters.offset, - requestParameters.sortby, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, options, ) .then((request) => request(axios, basePath)) }, /** - * Get a singe related learning resource for a learning resource. - * @summary Nested Learning Resource Retrieve - * @param {LearningResourcesApiLearningResourcesItemsRetrieveRequest} requestParameters Request parameters. + * Set User List Relationships on a given Learning Resource. + * @summary Set User List Relationships + * @param {LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningResourcesItemsRetrieve( - requestParameters: LearningResourcesApiLearningResourcesItemsRetrieveRequest, + learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp - .learningResourcesItemsRetrieve( - requestParameters.id, + .learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, options, ) .then((request) => request(axios, basePath)) }, /** - * Get a paginated list of learning resources. - * @summary List - * @param {LearningResourcesApiLearningResourcesListRequest} requestParameters Request parameters. + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsUpdateRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningResourcesList( - requestParameters: LearningResourcesApiLearningResourcesListRequest = {}, + learningResourcesRelationshipsUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsUpdateRequest, options?: RawAxiosRequestConfig, - ): AxiosPromise { + ): AxiosPromise { return localVarFp - .learningResourcesList( - requestParameters.certification, - requestParameters.certification_type, - requestParameters.course_feature, - requestParameters.department, - requestParameters.free, - requestParameters.learning_format, - requestParameters.level, - requestParameters.limit, - requestParameters.offered_by, - requestParameters.offset, - requestParameters.platform, - requestParameters.professional, - requestParameters.readable_id, - requestParameters.resource_category, - requestParameters.resource_type, - requestParameters.sortby, - requestParameters.topic, + .learningResourcesRelationshipsUpdate( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.LearningResourceRelationshipRequest, + requestParameters.learning_path_id, + requestParameters.userlist_id, options, ) .then((request) => request(axios, basePath)) @@ -11390,74 +12532,361 @@ export interface LearningResourcesApiLearningResourcesListRequest { readonly level?: Array /** - * Number of results to return per page. - * @type {number} - * @memberof LearningResourcesApiLearningResourcesList + * Number of results to return per page. + * @type {number} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly limit?: number + + /** + * The organization that offers a learning resource * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education + * @type {Array<'bootcamps' | 'mitpe' | 'mitx' | 'ocw' | 'see' | 'xpro'>} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly offered_by?: Array + + /** + * The initial index from which to return the results. + * @type {number} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly offset?: number + + /** + * The platform on which learning resources are offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube + * @type {Array<'bootcamps' | 'csail' | 'ctl' | 'edx' | 'emeritus' | 'globalalumni' | 'mitpe' | 'mitxonline' | 'ocw' | 'oll' | 'podcast' | 'scc' | 'see' | 'simplilearn' | 'susskind' | 'whu' | 'xpro' | 'youtube'>} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly platform?: Array + + /** + * + * @type {boolean} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly professional?: boolean + + /** + * Multiple values may be separated by commas. + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly readable_id?: Array + + /** + * The resource category of the learning resources * `course` - Course * `program` - Program * `learning_material` - Learning Material + * @type {Array<'course' | 'learning_material' | 'program'>} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly resource_category?: Array + + /** + * The type of learning resource * `course` - Course * `program` - Program * `learning_path` - Learning Path * `podcast` - Podcast * `podcast_episode` - Podcast Episode * `video` - Video * `video_playlist` - Video Playlist + * @type {Array<'course' | 'learning_path' | 'podcast' | 'podcast_episode' | 'program' | 'video' | 'video_playlist'>} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly resource_type?: Array + + /** + * Sort By * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending + * @type {'-id' | '-last_modified' | '-mitcoursenumber' | '-readable_id' | '-start_date' | '-views' | 'id' | 'last_modified' | 'mitcoursenumber' | 'new' | 'readable_id' | 'start_date' | 'upcoming' | 'views'} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly sortby?: LearningResourcesListSortbyEnum + + /** + * Multiple values may be separated by commas. + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesList + */ + readonly topic?: Array +} + +/** + * Request parameters for learningResourcesRelationshipsCreate operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsCreateRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsCreateRequest { + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsCreate + */ + readonly learning_resource_id: number + + /** + * + * @type {LearningResourceRelationshipRequest} + * @memberof LearningResourcesApiLearningResourcesRelationshipsCreate + */ + readonly LearningResourceRelationshipRequest: LearningResourceRelationshipRequest + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsCreate + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsCreate + */ + readonly userlist_id?: Array +} + +/** + * Request parameters for learningResourcesRelationshipsDestroy operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsDestroyRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsDestroyRequest { + /** + * + * @type {string} + * @memberof LearningResourcesApiLearningResourcesRelationshipsDestroy + */ + readonly id: string + + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsDestroy + */ + readonly learning_resource_id: number + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsDestroy + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsDestroy + */ + readonly userlist_id?: Array +} + +/** + * Request parameters for learningResourcesRelationshipsList operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsListRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsListRequest { + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsList + */ + readonly learning_resource_id: number + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsList + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsList + */ + readonly userlist_id?: Array +} + +/** + * Request parameters for learningResourcesRelationshipsPartialUpdate operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest { + /** + * + * @type {string} + * @memberof LearningResourcesApiLearningResourcesRelationshipsPartialUpdate + */ + readonly id: string + + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsPartialUpdate + */ + readonly learning_resource_id: number + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsPartialUpdate + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsPartialUpdate + */ + readonly userlist_id?: Array + + /** + * + * @type {PatchedLearningResourceRelationshipRequest} + * @memberof LearningResourcesApiLearningResourcesRelationshipsPartialUpdate + */ + readonly PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest +} + +/** + * Request parameters for learningResourcesRelationshipsRetrieve operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest { + /** + * + * @type {string} + * @memberof LearningResourcesApiLearningResourcesRelationshipsRetrieve + */ + readonly id: string + + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsRetrieve + */ + readonly learning_resource_id: number + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsRetrieve + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsRetrieve + */ + readonly userlist_id?: Array +} + +/** + * Request parameters for learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest { + /** + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate + */ + readonly learning_resource_id: number + + /** + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate + */ + readonly learning_path_id?: Array + + /** + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate + */ + readonly userlist_id?: Array + + /** + * + * @type {PatchedLearningResourceRelationshipRequest} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate */ - readonly limit?: number + readonly PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest +} +/** + * Request parameters for learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest { /** - * The organization that offers a learning resource * `mitx` - MITx * `ocw` - MIT OpenCourseWare * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education - * @type {Array<'bootcamps' | 'mitpe' | 'mitx' | 'ocw' | 'see' | 'xpro'>} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdate */ - readonly offered_by?: Array + readonly learning_resource_id: number /** - * The initial index from which to return the results. - * @type {number} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdate */ - readonly offset?: number + readonly learning_path_id?: Array /** - * The platform on which learning resources are offered * `edx` - edX * `ocw` - MIT OpenCourseWare * `oll` - Open Learning Library * `mitxonline` - MITx Online * `bootcamps` - Bootcamps * `xpro` - MIT xPRO * `csail` - CSAIL * `mitpe` - MIT Professional Education * `see` - MIT Sloan Executive Education * `scc` - Schwarzman College of Computing * `ctl` - Center for Transportation & Logistics * `whu` - WHU * `susskind` - Susskind * `globalalumni` - Global Alumni * `simplilearn` - Simplilearn * `emeritus` - Emeritus * `podcast` - Podcast * `youtube` - YouTube - * @type {Array<'bootcamps' | 'csail' | 'ctl' | 'edx' | 'emeritus' | 'globalalumni' | 'mitpe' | 'mitxonline' | 'ocw' | 'oll' | 'podcast' | 'scc' | 'see' | 'simplilearn' | 'susskind' | 'whu' | 'xpro' | 'youtube'>} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdate */ - readonly platform?: Array + readonly userlist_id?: Array /** * - * @type {boolean} - * @memberof LearningResourcesApiLearningResourcesList + * @type {PatchedLearningResourceRelationshipRequest} + * @memberof LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdate */ - readonly professional?: boolean + readonly PatchedLearningResourceRelationshipRequest?: PatchedLearningResourceRelationshipRequest +} +/** + * Request parameters for learningResourcesRelationshipsUpdate operation in LearningResourcesApi. + * @export + * @interface LearningResourcesApiLearningResourcesRelationshipsUpdateRequest + */ +export interface LearningResourcesApiLearningResourcesRelationshipsUpdateRequest { /** - * Multiple values may be separated by commas. - * @type {Array} - * @memberof LearningResourcesApiLearningResourcesList + * + * @type {string} + * @memberof LearningResourcesApiLearningResourcesRelationshipsUpdate */ - readonly readable_id?: Array + readonly id: string /** - * The resource category of the learning resources * `course` - Course * `program` - Program * `learning_material` - Learning Material - * @type {Array<'course' | 'learning_material' | 'program'>} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent learning resource + * @type {number} + * @memberof LearningResourcesApiLearningResourcesRelationshipsUpdate */ - readonly resource_category?: Array + readonly learning_resource_id: number /** - * The type of learning resource * `course` - Course * `program` - Program * `learning_path` - Learning Path * `podcast` - Podcast * `podcast_episode` - Podcast Episode * `video` - Video * `video_playlist` - Video Playlist - * @type {Array<'course' | 'learning_path' | 'podcast' | 'podcast_episode' | 'program' | 'video' | 'video_playlist'>} - * @memberof LearningResourcesApiLearningResourcesList + * + * @type {LearningResourceRelationshipRequest} + * @memberof LearningResourcesApiLearningResourcesRelationshipsUpdate */ - readonly resource_type?: Array + readonly LearningResourceRelationshipRequest: LearningResourceRelationshipRequest /** - * Sort By * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending - * @type {'-id' | '-last_modified' | '-mitcoursenumber' | '-readable_id' | '-start_date' | '-views' | 'id' | 'last_modified' | 'mitcoursenumber' | 'new' | 'readable_id' | 'start_date' | 'upcoming' | 'views'} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent learning path + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsUpdate */ - readonly sortby?: LearningResourcesListSortbyEnum + readonly learning_path_id?: Array /** - * Multiple values may be separated by commas. - * @type {Array} - * @memberof LearningResourcesApiLearningResourcesList + * id of the parent user list + * @type {Array} + * @memberof LearningResourcesApiLearningResourcesRelationshipsUpdate */ - readonly topic?: Array + readonly userlist_id?: Array } /** @@ -11609,6 +13038,184 @@ export class LearningResourcesApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)) } + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsCreateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsCreate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsCreateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsCreate( + requestParameters.learning_resource_id, + requestParameters.LearningResourceRelationshipRequest, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsDestroyRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsDestroy( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsDestroyRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsDestroy( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsListRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsList( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsListRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsList( + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsPartialUpdate( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsRetrieve( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsRetrieveRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsRetrieve( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Set Learning Path relationships for a given Learning Resource + * @param {LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Set User List Relationships on a given Learning Resource. + * @summary Set User List Relationships + * @param {LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( + requestParameters.learning_resource_id, + requestParameters.learning_path_id, + requestParameters.userlist_id, + requestParameters.PatchedLearningResourceRelationshipRequest, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Viewset for managing relationships between Learning Resources and User Lists / Learning Paths + * @param {LearningResourcesApiLearningResourcesRelationshipsUpdateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LearningResourcesApi + */ + public learningResourcesRelationshipsUpdate( + requestParameters: LearningResourcesApiLearningResourcesRelationshipsUpdateRequest, + options?: RawAxiosRequestConfig, + ) { + return LearningResourcesApiFp(this.configuration) + .learningResourcesRelationshipsUpdate( + requestParameters.id, + requestParameters.learning_resource_id, + requestParameters.LearningResourceRelationshipRequest, + requestParameters.learning_path_id, + requestParameters.userlist_id, + options, + ) + .then((request) => request(this.axios, this.basePath)) + } + /** * Retrieve a single learning resource. * @summary Retrieve @@ -15295,74 +16902,8 @@ export const LearningpathsApiAxiosParamCreator = function ( localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Viewset for LearningPath related resources - * @summary Learning Path Resource Relationship Update - * @param {number} id A unique integer value identifying this learning resource relationship. - * @param {number} learning_resource_id The learning resource id of the learning path - * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learningpathsItemsPartialUpdate: async ( - id: number, - learning_resource_id: number, - PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("learningpathsItemsPartialUpdate", "id", id) - // verify required parameter 'learning_resource_id' is not null or undefined - assertParamExists( - "learningpathsItemsPartialUpdate", - "learning_resource_id", - learning_resource_id, - ) - const localVarPath = - `/api/v1/learningpaths/{learning_resource_id}/items/{id}/` - .replace(`{${"id"}}`, encodeURIComponent(String(id))) - .replace( - `{${"learning_resource_id"}}`, - encodeURIComponent(String(learning_resource_id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "PATCH", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - PatchedLearningPathRelationshipRequest, - localVarRequestOptions, - configuration, - ) + ...options.headers, + } return { url: toPathString(localVarUrlObj), @@ -15370,23 +16911,25 @@ export const LearningpathsApiAxiosParamCreator = function ( } }, /** - * Get a singe related learning resource for a learning resource. - * @summary Nested Learning Resource Retrieve + * Viewset for LearningPath related resources + * @summary Learning Path Resource Relationship Update * @param {number} id A unique integer value identifying this learning resource relationship. * @param {number} learning_resource_id The learning resource id of the learning path + * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningpathsItemsRetrieve: async ( + learningpathsItemsPartialUpdate: async ( id: number, learning_resource_id: number, + PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'id' is not null or undefined - assertParamExists("learningpathsItemsRetrieve", "id", id) + assertParamExists("learningpathsItemsPartialUpdate", "id", id) // verify required parameter 'learning_resource_id' is not null or undefined assertParamExists( - "learningpathsItemsRetrieve", + "learningpathsItemsPartialUpdate", "learning_resource_id", learning_resource_id, ) @@ -15405,13 +16948,15 @@ export const LearningpathsApiAxiosParamCreator = function ( } const localVarRequestOptions = { - method: "GET", + method: "PATCH", ...baseOptions, ...options, } const localVarHeaderParameter = {} as any const localVarQueryParameter = {} as any + localVarHeaderParameter["Content-Type"] = "application/json" + setSearchParams(localVarUrlObj, localVarQueryParameter) let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {} @@ -15420,6 +16965,11 @@ export const LearningpathsApiAxiosParamCreator = function ( ...headersFromBaseOptions, ...options.headers, } + localVarRequestOptions.data = serializeDataIfNeeded( + PatchedLearningPathRelationshipRequest, + localVarRequestOptions, + configuration, + ) return { url: toPathString(localVarUrlObj), @@ -15427,28 +16977,33 @@ export const LearningpathsApiAxiosParamCreator = function ( } }, /** - * Set all relationships at once + * Get a singe related learning resource for a learning resource. + * @summary Nested Learning Resource Retrieve + * @param {number} id A unique integer value identifying this learning resource relationship. * @param {number} learning_resource_id The learning resource id of the learning path - * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - learningpathsItemsSetAllPartialUpdate: async ( + learningpathsItemsRetrieve: async ( + id: number, learning_resource_id: number, - PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, options: RawAxiosRequestConfig = {}, ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("learningpathsItemsRetrieve", "id", id) // verify required parameter 'learning_resource_id' is not null or undefined assertParamExists( - "learningpathsItemsSetAllPartialUpdate", + "learningpathsItemsRetrieve", "learning_resource_id", learning_resource_id, ) const localVarPath = - `/api/v1/learningpaths/{learning_resource_id}/items/set_all/`.replace( - `{${"learning_resource_id"}}`, - encodeURIComponent(String(learning_resource_id)), - ) + `/api/v1/learningpaths/{learning_resource_id}/items/{id}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace( + `{${"learning_resource_id"}}`, + encodeURIComponent(String(learning_resource_id)), + ) // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) let baseOptions @@ -15457,15 +17012,13 @@ export const LearningpathsApiAxiosParamCreator = function ( } const localVarRequestOptions = { - method: "PATCH", + method: "GET", ...baseOptions, ...options, } const localVarHeaderParameter = {} as any const localVarQueryParameter = {} as any - localVarHeaderParameter["Content-Type"] = "application/json" - setSearchParams(localVarUrlObj, localVarQueryParameter) let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {} @@ -15474,11 +17027,6 @@ export const LearningpathsApiAxiosParamCreator = function ( ...headersFromBaseOptions, ...options.headers, } - localVarRequestOptions.data = serializeDataIfNeeded( - PatchedLearningPathRelationshipRequest, - localVarRequestOptions, - configuration, - ) return { url: toPathString(localVarUrlObj), @@ -15990,42 +17538,6 @@ export const LearningpathsApiFp = function (configuration?: Configuration) { configuration, )(axios, operationBasePath || basePath) }, - /** - * Set all relationships at once - * @param {number} learning_resource_id The learning resource id of the learning path - * @param {PatchedLearningPathRelationshipRequest} [PatchedLearningPathRelationshipRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async learningpathsItemsSetAllPartialUpdate( - learning_resource_id: number, - PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.learningpathsItemsSetAllPartialUpdate( - learning_resource_id, - PatchedLearningPathRelationshipRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap[ - "LearningpathsApi.learningpathsItemsSetAllPartialUpdate" - ]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, /** * Get a paginated list of learning paths * @summary List @@ -16318,24 +17830,6 @@ export const LearningpathsApiFactory = function ( ) .then((request) => request(axios, basePath)) }, - /** - * Set all relationships at once - * @param {LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learningpathsItemsSetAllPartialUpdate( - requestParameters: LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .learningpathsItemsSetAllPartialUpdate( - requestParameters.learning_resource_id, - requestParameters.PatchedLearningPathRelationshipRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, /** * Get a paginated list of learning paths * @summary List @@ -16561,27 +18055,6 @@ export interface LearningpathsApiLearningpathsItemsRetrieveRequest { readonly learning_resource_id: number } -/** - * Request parameters for learningpathsItemsSetAllPartialUpdate operation in LearningpathsApi. - * @export - * @interface LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest - */ -export interface LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest { - /** - * The learning resource id of the learning path - * @type {number} - * @memberof LearningpathsApiLearningpathsItemsSetAllPartialUpdate - */ - readonly learning_resource_id: number - - /** - * - * @type {PatchedLearningPathRelationshipRequest} - * @memberof LearningpathsApiLearningpathsItemsSetAllPartialUpdate - */ - readonly PatchedLearningPathRelationshipRequest?: PatchedLearningPathRelationshipRequest -} - /** * Request parameters for learningpathsList operation in LearningpathsApi. * @export @@ -16895,26 +18368,6 @@ export class LearningpathsApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)) } - /** - * Set all relationships at once - * @param {LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof LearningpathsApi - */ - public learningpathsItemsSetAllPartialUpdate( - requestParameters: LearningpathsApiLearningpathsItemsSetAllPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ) { - return LearningpathsApiFp(this.configuration) - .learningpathsItemsSetAllPartialUpdate( - requestParameters.learning_resource_id, - requestParameters.PatchedLearningPathRelationshipRequest, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - /** * Get a paginated list of learning paths * @summary List @@ -21526,65 +22979,6 @@ export const UserlistsApiAxiosParamCreator = function ( options: localVarRequestOptions, } }, - /** - * Set all relationships at once - * @param {number} userlist_id id of the parent user list - * @param {PatchedUserListRelationshipRequest} [PatchedUserListRelationshipRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - userlistsItemsSetAllPartialUpdate: async ( - userlist_id: number, - PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'userlist_id' is not null or undefined - assertParamExists( - "userlistsItemsSetAllPartialUpdate", - "userlist_id", - userlist_id, - ) - const localVarPath = - `/api/v1/userlists/{userlist_id}/items/set_all/`.replace( - `{${"userlist_id"}}`, - encodeURIComponent(String(userlist_id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "PATCH", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - PatchedUserListRelationshipRequest, - localVarRequestOptions, - configuration, - ) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, /** * Viewset for UserLists * @summary List @@ -21980,42 +23374,6 @@ export const UserlistsApiFp = function (configuration?: Configuration) { configuration, )(axios, operationBasePath || basePath) }, - /** - * Set all relationships at once - * @param {number} userlist_id id of the parent user list - * @param {PatchedUserListRelationshipRequest} [PatchedUserListRelationshipRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async userlistsItemsSetAllPartialUpdate( - userlist_id: number, - PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.userlistsItemsSetAllPartialUpdate( - userlist_id, - PatchedUserListRelationshipRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["UserlistsApi.userlistsItemsSetAllPartialUpdate"]?.[ - index - ]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, /** * Viewset for UserLists * @summary List @@ -22249,24 +23607,6 @@ export const UserlistsApiFactory = function ( ) .then((request) => request(axios, basePath)) }, - /** - * Set all relationships at once - * @param {UserlistsApiUserlistsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - userlistsItemsSetAllPartialUpdate( - requestParameters: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .userlistsItemsSetAllPartialUpdate( - requestParameters.userlist_id, - requestParameters.PatchedUserListRelationshipRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, /** * Viewset for UserLists * @summary List @@ -22470,27 +23810,6 @@ export interface UserlistsApiUserlistsItemsRetrieveRequest { readonly userlist_id: number } -/** - * Request parameters for userlistsItemsSetAllPartialUpdate operation in UserlistsApi. - * @export - * @interface UserlistsApiUserlistsItemsSetAllPartialUpdateRequest - */ -export interface UserlistsApiUserlistsItemsSetAllPartialUpdateRequest { - /** - * id of the parent user list - * @type {number} - * @memberof UserlistsApiUserlistsItemsSetAllPartialUpdate - */ - readonly userlist_id: number - - /** - * - * @type {PatchedUserListRelationshipRequest} - * @memberof UserlistsApiUserlistsItemsSetAllPartialUpdate - */ - readonly PatchedUserListRelationshipRequest?: PatchedUserListRelationshipRequest -} - /** * Request parameters for userlistsList operation in UserlistsApi. * @export @@ -22695,26 +24014,6 @@ export class UserlistsApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)) } - /** - * Set all relationships at once - * @param {UserlistsApiUserlistsItemsSetAllPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof UserlistsApi - */ - public userlistsItemsSetAllPartialUpdate( - requestParameters: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ) { - return UserlistsApiFp(this.configuration) - .userlistsItemsSetAllPartialUpdate( - requestParameters.userlist_id, - requestParameters.PatchedUserListRelationshipRequest, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - /** * Viewset for UserLists * @summary List diff --git a/frontends/api/src/hooks/learningResources/index.ts b/frontends/api/src/hooks/learningResources/index.ts index 4b19e60178..fcd29a814e 100644 --- a/frontends/api/src/hooks/learningResources/index.ts +++ b/frontends/api/src/hooks/learningResources/index.ts @@ -5,7 +5,11 @@ import { useQuery, useQueryClient, } from "@tanstack/react-query" -import { learningpathsApi, userListsApi } from "../../clients" +import { + learningpathsApi, + learningResourcesApi, + userListsApi, +} from "../../clients" import type { LearningResourcesApiLearningResourcesListRequest as LRListRequest, TopicsApiTopicsListRequest as TopicsListRequest, @@ -28,7 +32,8 @@ import type { PlatformsApiPlatformsListRequest, FeaturedApiFeaturedListRequest as FeaturedListParams, PaginatedLearningResourceList, - UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, + LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest, + LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest, } from "../../generated/v1" import learningResources, { invalidateResourceQueries, @@ -320,23 +325,57 @@ const useUserListRelationshipCreate = () => { }) } -const useUserListSetAllRelationships = () => { +const useLearningResourceSetUserListRelationships = () => { + const queryClient = useQueryClient() + return useMutation({ + mutationFn: ( + params: LearningResourcesApiLearningResourcesRelationshipsSetUserListRelationshipsPartialUpdateRequest, + ) => + learningResourcesApi.learningResourcesRelationshipsSetUserListRelationshipsPartialUpdate( + params, + ), + onSuccess: (response, _vars) => { + queryClient.setQueriesData( + learningResources.featured({}).queryKey, + (old) => updateListParentsOnAdd(response.data, old), + ) + }, + onSettled: (_response, _err, vars) => { + invalidateResourceQueries(queryClient, vars.learning_resource_id, { + skipFeatured: true, + }) + vars.userlist_id?.forEach((userlistId) => { + invalidateUserListQueries(queryClient, userlistId) + }) + }, + }) +} + +const useLearningResourceSetLearningPathRelationships = () => { const queryClient = useQueryClient() return useMutation({ mutationFn: ( - params: UserlistsApiUserlistsItemsSetAllPartialUpdateRequest, - ) => userListsApi.userlistsItemsSetAllPartialUpdate(params), - // userListsApi.userlistsItemsCreate({ - // userlist_id: params.parent, - // UserListRelationshipRequest: params, - // }), + params: LearningResourcesApiLearningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdateRequest, + ) => + learningResourcesApi.learningResourcesRelationshipsSetLearningPathRelationshipsPartialUpdate( + params, + ), onSuccess: (response, _vars) => { queryClient.setQueriesData( learningResources.featured({}).queryKey, (old) => updateListParentsOnAdd(response.data, old), ) }, - onSettled: (_response, _err, vars) => {}, + onSettled: (_response, _err, vars) => { + invalidateResourceQueries(queryClient, vars.learning_resource_id, { + skipFeatured: true, + }) + vars.learning_path_id?.forEach((learningPathId) => { + invalidateResourceQueries(queryClient, learningPathId, { + skipFeatured: true, + }) + }) + }, }) } @@ -475,6 +514,8 @@ export { useLearningpathRelationshipCreate, useLearningpathRelationshipDestroy, useLearningResourcesSearch, + useLearningResourceSetUserListRelationships, + useLearningResourceSetLearningPathRelationships, useUserListList, useUserListsDetail, useUserListCreate, @@ -483,7 +524,6 @@ export { useUserListRelationshipMove, useUserListRelationshipCreate, useUserListRelationshipDestroy, - useUserListSetAllRelationships, useInfiniteUserListItems, useOfferorsList, useListItemMove, diff --git a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx index 73c246bdcd..a855896e7b 100644 --- a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx +++ b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx @@ -1,20 +1,15 @@ -import React, { useId, useState } from "react" +import React, { useCallback, useId } from "react" import { Dialog, - Chip, - MuiCheckbox, - List, - ListItem, - ListItemButton, - ListItemText, LoadingSpinner, Typography, styled, CheckboxChoiceField, Button, + CircularProgress, } from "ol-components" -import { RiLockLine, RiLockUnlockLine, RiAddLine } from "@remixicon/react" +import { RiAddLine } from "@remixicon/react" import * as NiceModal from "@ebay/nice-modal-react" @@ -25,180 +20,32 @@ import { } from "api" import { + useLearningResourceSetUserListRelationships, useLearningPathsList, useLearningResourcesDetail, - useLearningpathRelationshipCreate, - useLearningpathRelationshipDestroy, useUserListList, - useUserListRelationshipCreate, - useUserListRelationshipDestroy, - useUserListSetAllRelationships, + useLearningResourceSetLearningPathRelationships, } from "api/hooks/learningResources" import { manageListDialogs } from "@/page-components/ManageListDialogs/ManageListDialogs" import { ListType } from "api/constants" import { useFormik } from "formik" -const useLearningPathRequestRecord = () => { - const [pending, setPending] = useState>( - new Map(), - ) - const key = (resource: LearningResource, list: LearningPathResource) => - `${resource.id}-${list.id}` - const get = (resource: LearningResource, list: LearningPathResource) => - pending.get(key(resource, list)) - const set = ( - resource: LearningResource, - list: LearningPathResource, - value: "delete" | "add", - ) => { - setPending((current) => new Map(current).set(key(resource, list), value)) - } - const clear = (resource: LearningResource, list: LearningPathResource) => { - setPending((current) => { - const next = new Map(current) - next.delete(key(resource, list)) - return next - }) - } - return { get, set, clear } -} - -const useUserListRequestRecord = () => { - const [pending, setPending] = useState>( - new Map(), - ) - const key = (resource: LearningResource, list: UserList) => - `${resource.id}-${list.id}` - const get = (resource: LearningResource, list: UserList) => - pending.get(key(resource, list)) - const set = ( - resource: LearningResource, - list: UserList, - value: "delete" | "add", - ) => { - setPending((current) => new Map(current).set(key(resource, list), value)) - } - const clear = (resource: LearningResource, list: UserList) => { - setPending((current) => { - const next = new Map(current) - next.delete(key(resource, list)) - return next - }) - } - return { get, set, clear } -} - -const useToggleItemInLearningPath = (resource?: LearningResource) => { - const requestRecord = useLearningPathRequestRecord() - const addTo = useLearningpathRelationshipCreate() - const deleteFrom = useLearningpathRelationshipDestroy() - const handleAdd = async (list: LearningPathResource) => { - if (!resource) return - requestRecord.set(resource, list, "add") - try { - await addTo.mutateAsync({ child: resource.id, parent: list.id }) - } finally { - requestRecord.clear(resource, list) - } - } - const handleRemove = async (list: LearningPathResource) => { - if (!resource) return - requestRecord.set(resource, list, "delete") - const relationship = resource.learning_path_parents?.find( - ({ parent }) => parent === list.id, - ) - if (!relationship) return // should not happen - try { - await deleteFrom.mutateAsync(relationship) - } finally { - requestRecord.clear(resource, list) - } - } - - const isChecked = (list: LearningPathResource): boolean => - resource?.learning_path_parents?.some(({ parent }) => parent === list.id) ?? - false - - const isAdding = (list: LearningPathResource) => - !!resource && requestRecord.get(resource, list) === "add" - const isRemoving = (list: LearningPathResource) => - !!resource && requestRecord.get(resource, list) === "delete" - - const handleToggle = (list: LearningPathResource) => async () => { - return isChecked(list) ? handleRemove(list) : handleAdd(list) - } - return { handleToggle, isChecked, isAdding, isRemoving } -} - -const useToggleItemInUserList = (resource?: LearningResource) => { - const requestRecord = useUserListRequestRecord() - const addTo = useUserListRelationshipCreate() - const deleteFrom = useUserListRelationshipDestroy() - const handleAdd = async (list: UserList) => { - if (!resource) return - requestRecord.set(resource, list, "add") - try { - await addTo.mutateAsync({ child: resource.id, parent: list.id }) - } finally { - requestRecord.clear(resource, list) - } - } - const handleRemove = async (list: UserList) => { - if (!resource) return - requestRecord.set(resource, list, "delete") - const relationship = resource.user_list_parents?.find( - ({ parent }) => parent === list.id, - ) - if (!relationship) return // should not happen - try { - await deleteFrom.mutateAsync(relationship) - } finally { - requestRecord.clear(resource, list) - } - } - - const isChecked = (list: UserList): boolean => - resource?.user_list_parents?.some(({ parent }) => parent === list.id) ?? - false - - const isAdding = (list: UserList) => - !!resource && requestRecord.get(resource, list) === "add" - const isRemoving = (list: UserList) => - !!resource && requestRecord.get(resource, list) === "delete" - - const handleToggle = (list: UserList) => async () => { - return isChecked(list) ? handleRemove(list) : handleAdd(list) - } - return { handleToggle, isChecked, isAdding, isRemoving } -} - const ResourceTitle = styled.span({ fontStyle: "italic", }) -const Listing = styled(List)` - & .MuiListItem-root:not(.add-to-list-new) { - padding: 0; - } - - .MuiListItemButton-root:not(.add-to-list-new) { - padding-top: 0; - padding-bottom: 0; - } -` +const CheckboxContainer = styled.div({ + padding: "28px 0", +}) -type PrivacyChipProps = { - publicOption: string - selectedOption: string | undefined -} -const PrivacyChip: React.FC = ({ - publicOption, - selectedOption, -}) => { - const isPublic = selectedOption === publicOption - const icon = isPublic ? : - return -} +const ButtonContainer = styled.div({ + display: "flex", + gap: "12px", + alignItems: "flex-start", + button: { + width: "50%", + }, +}) type AddToListDialogInnerProps = { listType: ListType @@ -213,7 +60,23 @@ const AddToListDialogInner: React.FC = ({ isReady, }) => { const modal = NiceModal.useModal() - const setUserListRelationships = useUserListSetAllRelationships() + const handleCreate = useCallback(() => { + if (listType === ListType.LearningPath) { + manageListDialogs.upsertLearningPath() + } else if (listType === ListType.UserList) { + manageListDialogs.upsertUserList() + } + }, [listType]) + const { + isLoading: isSavingUserListRelationships, + mutateAsync: setUserListRelationships, + } = useLearningResourceSetUserListRelationships() + const { + isLoading: isSavingLearningPathRelationships, + mutateAsync: setLearningPathRelationships, + } = useLearningResourceSetLearningPathRelationships() + const isSaving = + isSavingLearningPathRelationships || isSavingUserListRelationships let dialogTitle = "Add to list" if (listType === ListType.LearningPath) { dialogTitle = "Add to Learning List" @@ -247,25 +110,24 @@ const AddToListDialogInner: React.FC = ({ learning_paths: learningPathValues, user_lists: userListValues, }, - onSubmit: () => {}, - }) - const save = async (values: { learning_paths: string[]; user_lists: string[] }) => { - if (formik.dirty) { - console.log(values) - if (listType === ListType.LearningPath) { - } - else if (listType === ListType.UserList) { - if (resource) { + onSubmit: (values) => { + if (resource) { + if (listType === ListType.LearningPath) { + const newParents = values.learning_paths.map((id) => parseInt(id)) + setLearningPathRelationships({ + learning_resource_id: resource.id, + learning_path_id: newParents, + }) + } else if (listType === ListType.UserList) { const newParents = values.user_lists.map((id) => parseInt(id)) - const removedParents = listChoices.map((list) => list.value).filter((id) => !newParents.includes(parseInt(id))) - await setUserListRelationships.mutateAsync({ - child: resource.id, - add_parents: newParents, - remove_parents: removedParents + setUserListRelationships({ + learning_resource_id: resource.id, + userlist_id: newParents, }) + } } - } - } + }, + }) return ( = ({ > {isReady ? (
- + Adding {resource?.title} - {listType === ListType.LearningPath ? ( + + {listType === ListType.LearningPath ? ( - ) : null} - {listType === ListType.UserList ? ( + ) : null} + {listType === ListType.UserList ? ( - ) : null} -
+ ) : null} + + -
+ ) : ( @@ -323,84 +187,6 @@ const AddToListDialogInner: React.FC = ({ ) } -type LearningPathToggleListProps = { - resource: LearningResource | undefined - lists: LearningPathResource[] -} -const LearningPathToggleList: React.FC = ({ - resource, - lists, -}) => { - const { handleToggle, isChecked, isAdding, isRemoving } = - useToggleItemInLearningPath(resource) - return lists.map((list) => { - const checked = isChecked(list) - const adding = isAdding(list) - const removing = isRemoving(list) - const disabled = adding || removing - return ( - - } - > - - - - - - ) - }) -} - -type UserListToggleListProps = { - resource: LearningResource | undefined - lists: UserList[] -} -const UserListToggleList: React.FC = ({ - resource, - lists, -}) => { - const { handleToggle, isChecked, isAdding, isRemoving } = - useToggleItemInUserList(resource) - return lists.map((list) => { - const checked = isChecked(list) - const adding = isAdding(list) - const removing = isRemoving(list) - const disabled = adding || removing - return ( - - - - - - - ) - }) -} - type AddToListDialogProps = { resourceId: number } diff --git a/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx b/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx index 452267863a..6c5b5482f2 100644 --- a/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx +++ b/frontends/ol-components/src/components/Checkbox/CheckboxChoiceField.tsx @@ -5,7 +5,7 @@ import FormLabel from "@mui/material/FormLabel" import styled from "@emotion/styled" export type CheckboxChoiceFieldProps = { - label: React.ReactNode // We could make this optional, but we should demand one of (label, aria-label, aria-labelledby) + label?: React.ReactNode // We could make this optional, but we should demand one of (label, aria-label, aria-labelledby) value?: string[] name: string choices: Omit[] @@ -55,7 +55,7 @@ const CheckboxChoiceField: React.FC = ({ sx={{ width: "100%" }} className={className} > - + {label && } <_Container> {choices.map((choice) => { return ( diff --git a/learning_resources/urls.py b/learning_resources/urls.py index f50cd0c5c4..fd33f123ad 100644 --- a/learning_resources/urls.py +++ b/learning_resources/urls.py @@ -24,7 +24,11 @@ views.LearningResourceContentFilesViewSet, basename="learning_resource_content_files_api", ) - +learning_resource_list_relationships = nested_learning_resources_router.register( + r"relationships", + views.LearningResourceListRelationshipViewSet, + basename="learning_resource_relationships_api", +) router.register(r"courses", views.CourseViewSet, basename="courses_api") nested_courses_router = NestedSimpleRouter( diff --git a/learning_resources/views.py b/learning_resources/views.py index 4b0b88d2be..0f9735bf1f 100644 --- a/learning_resources/views.py +++ b/learning_resources/views.py @@ -27,6 +27,7 @@ from channels.models import Channel from learning_resources import permissions from learning_resources.constants import ( + LearningResourceRelationTypes, LearningResourceType, PlatformType, PrivacyLevel, @@ -377,6 +378,90 @@ class ResourceListItemsViewSet(NestedViewSetMixin, viewsets.ReadOnlyModelViewSet ordering = ["position", "-child__last_modified"] +@extend_schema_view( + set_user_list_relationships=extend_schema( + summary="Set User List Relationships", + description="Set User List Relationships on a given Learning Resource.", + ), +) +@extend_schema( + parameters=[ + OpenApiParameter( + name="learning_resource_id", + type=OpenApiTypes.INT, + location=OpenApiParameter.PATH, + description="id of the parent learning resource", + ), + OpenApiParameter( + name="userlist_id", + type=OpenApiTypes.INT, + many=True, + location=OpenApiParameter.QUERY, + description="id of the parent user list", + ), + OpenApiParameter( + name="learning_path_id", + type=OpenApiTypes.INT, + many=True, + location=OpenApiParameter.QUERY, + description="id of the parent learning path", + ), + ] +) +class LearningResourceListRelationshipViewSet( + NestedViewSetMixin, viewsets.ModelViewSet +): + """ + Viewset for managing relationships between Learning Resources + and User Lists / Learning Paths + """ + + parent_lookup_kwargs = {"learning_resource_id": "parent_id"} + permission_classes = (AnonymousAccessReadonlyPermission,) + filter_backends = [MultipleOptionsFilterBackend] + filterset_class = LearningResourceFilter + serializer_class = LearningResourceRelationshipSerializer + + @action(detail=False, methods=["patch"], name="Set User List Relationships") + def set_user_list_relationships(self, request, *args, **kwargs): # noqa: ARG002 + """ + Set User List relationships for a given Learning Resource + """ + learning_resource_id = kwargs.get("learning_resource_id") + user_list_ids = request.query_params.getlist("userlist_id") + current_relationships = UserListRelationship.objects.filter( + child_id=learning_resource_id + ) + current_relationships.exclude(parent_id__in=user_list_ids).delete() + for index, userlist_id in enumerate(user_list_ids): + UserListRelationship.objects.create( + parent_id=userlist_id, child_id=learning_resource_id, position=index + ) + serializer = self.get_serializer(current_relationships, many=True) + return Response(serializer.data) + + @action(detail=False, methods=["patch"], name="Set Learning Path Relationships") + def set_learning_path_relationships(self, request, *args, **kwargs): # noqa: ARG002 + """ + Set Learning Path relationships for a given Learning Resource + """ + learning_resource_id = kwargs.get("learning_resource_id") + learning_path_ids = request.query_params.getlist("learning_path_id") + current_relationships = LearningResourceRelationship.objects.filter( + child_id=learning_resource_id + ) + current_relationships.exclude(parent_id__in=learning_path_ids).delete() + for index, learning_path_id in enumerate(learning_path_ids): + LearningResourceRelationship.objects.create( + parent_id=learning_path_id, + child_id=learning_resource_id, + relation_type=LearningResourceRelationTypes.LEARNING_PATH_ITEMS, + position=index, + ) + serializer = self.get_serializer(current_relationships, many=True) + return Response(serializer.data) + + @extend_schema_view( create=extend_schema(summary="Learning Path Resource Relationship Add"), destroy=extend_schema(summary="Learning Path Resource Relationship Remove"), @@ -419,22 +504,6 @@ def perform_destroy(self, instance): ).update(position=F("position") - 1) instance.delete() - @action(detail=False, methods=["patch"], name="Set all Learning Path Relationships") - def set_all(self, request, *args, **kwargs): - """ - Set all relationships at once - """ - child_id = request.data.get("child") - add_parents = request.data.get("add_parents", []) - remove_parents = request.data.get("remove_parents", []) - LearningResourceRelationship.objects.filter( - parent_id__in=remove_parents, child_id=child_id - ).delete() - for parent_id in add_parents: - LearningResourceRelationship.objects.create( - parent_id=parent_id, child_id=child_id - ) - @extend_schema_view( list=extend_schema(summary="List"), @@ -598,20 +667,6 @@ def perform_destroy(self, instance): position__gt=instance.position, ).update(position=F("position") - 1) - @action(detail=False, methods=["patch"], name="Set all User List Relationships") - def set_all(self, request, *args, **kwargs): - """ - Set all relationships at once - """ - child_id = kwargs.get("child") - add_parents = kwargs.get("add_parents", []) - remove_parents = kwargs.get("remove_parents", []) - UserListRelationship.objects.filter( - parent_id__in=remove_parents, child_id=child_id - ).delete() - for parent_id in add_parents: - UserListRelationship.objects.create(parent_id=parent_id, child_id=child_id) - @cache_page(60 * settings.RSS_FEED_CACHE_MINUTES) def podcast_rss_feed(request): # noqa: ARG001 From 63363835b30b200c7c2b9a30b00089745bce662f Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Fri, 23 Aug 2024 18:07:44 -0400 Subject: [PATCH 03/33] remove the modal after we're done with it --- .../mit-learn/src/page-components/Dialogs/AddToListDialog.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx index a855896e7b..3b2a2457bd 100644 --- a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx +++ b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx @@ -125,6 +125,7 @@ const AddToListDialogInner: React.FC = ({ userlist_id: newParents, }) } + modal.remove() } }, }) From 18de40205d6a5a9416e7aaa28040165cf4b4ad29 Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Fri, 23 Aug 2024 18:08:43 -0400 Subject: [PATCH 04/33] await setting new list parents before dismissing modal --- .../src/page-components/Dialogs/AddToListDialog.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx index 3b2a2457bd..68622cb7ea 100644 --- a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx +++ b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx @@ -110,17 +110,17 @@ const AddToListDialogInner: React.FC = ({ learning_paths: learningPathValues, user_lists: userListValues, }, - onSubmit: (values) => { + onSubmit: async (values) => { if (resource) { if (listType === ListType.LearningPath) { const newParents = values.learning_paths.map((id) => parseInt(id)) - setLearningPathRelationships({ + await setLearningPathRelationships({ learning_resource_id: resource.id, learning_path_id: newParents, }) } else if (listType === ListType.UserList) { const newParents = values.user_lists.map((id) => parseInt(id)) - setUserListRelationships({ + await setUserListRelationships({ learning_resource_id: resource.id, userlist_id: newParents, }) From 519751324b20324ee15fd063970d6e7c4029b5b8 Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Mon, 26 Aug 2024 09:58:52 -0400 Subject: [PATCH 05/33] remove circularprogress for now --- .../mit-learn/src/page-components/Dialogs/AddToListDialog.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx index 68622cb7ea..7f19cd1855 100644 --- a/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx +++ b/frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx @@ -6,7 +6,6 @@ import { styled, CheckboxChoiceField, Button, - CircularProgress, } from "ol-components" import { RiAddLine } from "@remixicon/react" @@ -166,7 +165,6 @@ const AddToListDialogInner: React.FC = ({