diff --git a/cookbook/helper/permission_helper.py b/cookbook/helper/permission_helper.py index d889a747..9393292f 100644 --- a/cookbook/helper/permission_helper.py +++ b/cookbook/helper/permission_helper.py @@ -9,7 +9,7 @@ from django.utils.translation import gettext as _ from rest_framework import permissions from rest_framework.permissions import SAFE_METHODS -from cookbook.models import ShareLink, Recipe, UserPreference +from cookbook.models import ShareLink, Recipe, UserPreference, UserSpace def get_allowed_groups(groups_required): @@ -53,7 +53,6 @@ def is_object_owner(user, obj): Tests if a given user is the owner of a given object test performed by checking user against the objects user and create_by field (if exists) - superusers bypass all checks, unauthenticated users cannot own anything :param user django auth user object :param obj any object that should be tested :return: true if user is owner of object, false otherwise @@ -66,11 +65,25 @@ def is_object_owner(user, obj): return False +def is_space_owner(user, obj): + """ + Tests if a given user is the owner the space of a given object + :param user django auth user object + :param obj any object that should be tested + :return: true if user is owner of the objects space, false otherwise + """ + if not user.is_authenticated: + return False + try: + return obj.get_space().get_owner() == user + except Exception: + return False + + def is_object_shared(user, obj): """ Tests if a given user is shared for a given object test performed by checking user against the objects shared table - superusers bypass all checks, unauthenticated users cannot own anything :param user django auth user object :param obj any object that should be tested :return: true if user is shared for object, false otherwise @@ -184,7 +197,7 @@ class CustomIsOwner(permissions.BasePermission): verifies user has ownership over object (either user or created_by or user is request user) """ - message = _('You cannot interact with this object as it is not owned by you!') # noqa: E501 + message = _('You cannot interact with this object as it is not owned by you!') def has_permission(self, request, view): return request.user.is_authenticated @@ -193,6 +206,20 @@ class CustomIsOwner(permissions.BasePermission): return is_object_owner(request.user, obj) +class CustomIsSpaceOwner(permissions.BasePermission): + """ + Custom permission class for django rest framework views + verifies if the user is the owner of the space the object belongs to + """ + message = _('You cannot interact with this object as it is not owned by you!') + + def has_permission(self, request, view): + return request.user.is_authenticated + + def has_object_permission(self, request, view, obj): + return is_space_owner(request.user, obj) + + # TODO function duplicate/too similar name class CustomIsShared(permissions.BasePermission): """ @@ -293,7 +320,19 @@ def above_space_user_limit(space): :param space: Space to test for limits :return: Tuple (True if above or equal limit else false, message) """ - limit = space.max_users != 0 and UserPreference.objects.filter(space=space).count() > space.max_users + limit = space.max_users != 0 and UserSpace.objects.filter(space=space).count() > space.max_users if limit: return True, _('You have more users than allowed in your space.') return False, '' + + +def switch_user_active_space(user, user_space): + """ + Switch the currently active space of a user by setting all spaces to inactive and activating the one passed + :param user: user to change active space for + :param user_space: user space object to activate + """ + if not user_space.active: + UserSpace.objects.filter(user=user).update(active=False) # make sure to deactivate all spaces for a user + user_space.active = True + user_space.save() diff --git a/cookbook/models.py b/cookbook/models.py index 746414cb..c6918bf3 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -241,6 +241,9 @@ class Space(ExportModelOperationsMixin('space'), models.Model): food_inherit = models.ManyToManyField(FoodInheritField, blank=True) show_facet_count = models.BooleanField(default=False) + def get_owner(self): + return self.created_by + def __str__(self): return self.name diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 7867587b..edcc8d49 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -2,7 +2,7 @@ from datetime import timedelta from decimal import Decimal from gettext import gettext as _ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, Group from django.db.models import Avg, Q, QuerySet, Sum from django.urls import reverse from django.utils import timezone @@ -20,7 +20,7 @@ from cookbook.models import (Automation, BookmarkletImport, Comment, CookLog, Cu RecipeBookEntry, RecipeImport, ShareLink, ShoppingList, ShoppingListEntry, ShoppingListRecipe, Step, Storage, Supermarket, SupermarketCategory, SupermarketCategoryRelation, Sync, SyncLog, Unit, - UserFile, UserPreference, ViewLog) + UserFile, UserPreference, ViewLog, Space, UserSpace) from cookbook.templatetags.custom_tags import markdown from recipes.settings import MEDIA_URL, AWS_ENABLED @@ -123,6 +123,65 @@ class SpaceFilterSerializer(serializers.ListSerializer): return super().to_representation(data) +class UserNameSerializer(WritableNestedModelSerializer): + username = serializers.SerializerMethodField('get_user_label') + + def get_user_label(self, obj): + return obj.get_user_name() + + class Meta: + list_serializer_class = SpaceFilterSerializer + model = User + fields = ('id', 'username') + + +class GroupSerializer(WritableNestedModelSerializer): + def create(self, validated_data): + raise ValidationError('Cannot create using this endpoint') + + class Meta: + model = Group + fields = ('id', 'name') + + +class SpaceSerializer(serializers.ModelSerializer): + user_count = serializers.SerializerMethodField('get_user_count') + recipe_count = serializers.SerializerMethodField('get_recipe_count') + file_size_mb = serializers.SerializerMethodField('get_file_size_mb') + + def get_user_count(self, obj): + return UserSpace.objects.filter(space=obj).count() + + def get_recipe_count(self, obj): + return Recipe.objects.filter(space=obj).count() + + def get_file_size_mb(self, obj): + try: + return UserFile.objects.filter(space=obj).aggregate(Sum('file_size_kb'))['file_size_kb__sum'] / 1000 + except TypeError: + return 0 + + def create(self, validated_data): + raise ValidationError('Cannot create using this endpoint') + + class Meta: + model = Space + fields = ('id', 'name', 'created_by', 'created_at', 'message', 'max_recipes', 'max_file_storage_mb', 'max_users', 'allow_sharing', 'demo', 'food_inherit', 'show_facet_count', 'user_count', 'recipe_count', 'file_size_mb',) + read_only_fields = ('id', 'created_by', 'created_at', 'message', 'max_recipes', 'max_file_storage_mb', 'max_users', 'allow_sharing', 'demo',) + + +class UserSpaceSerializer(serializers.ModelSerializer): + user = UserNameSerializer(read_only=True) + + def create(self, validated_data): + raise ValidationError('Cannot create using this endpoint') + + class Meta: + model = UserSpace + fields = ('id', 'user', 'space', 'groups', 'created_at', 'updated_at',) + read_only_fields = ('id', 'created_at', 'updated_at', 'space') + + class SpacedModelSerializer(serializers.ModelSerializer): def create(self, validated_data): validated_data['space'] = self.context['request'].space @@ -142,18 +201,6 @@ class MealTypeSerializer(SpacedModelSerializer, WritableNestedModelSerializer): read_only_fields = ('created_by',) -class UserNameSerializer(WritableNestedModelSerializer): - username = serializers.SerializerMethodField('get_user_label') - - def get_user_label(self, obj): - return obj.get_user_name() - - class Meta: - list_serializer_class = SpaceFilterSerializer - model = User - fields = ('id', 'username') - - class FoodInheritFieldSerializer(WritableNestedModelSerializer): name = serializers.CharField(allow_null=True, allow_blank=True, required=False) field = serializers.CharField(allow_null=True, allow_blank=True, required=False) diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 820d8dbe..6ae13f27 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -346,7 +346,7 @@ {% message_of_the_day as message_of_the_day %} {% if message_of_the_day %} -
+
{{ message_of_the_day }}
{% endif %} diff --git a/cookbook/templates/space_manage.html b/cookbook/templates/space_manage.html new file mode 100644 index 00000000..e17eeccf --- /dev/null +++ b/cookbook/templates/space_manage.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% load render_bundle from webpack_loader %} +{% load static %} +{% load i18n %} +{% load l10n %} + +{% block title %}{% trans 'Search' %}{% endblock %} + +{% block content %} + +
+ + + +
+ +
+
+

+ {% trans 'Space:' %} {{ request.space.name }} + {% if HOSTED %} {% trans 'Manage Subscription' %} + {% endif %} +

+
+ +
+ +
+ +
+ + +{% endblock %} + + +{% block script %} + {% if debug %} + + {% else %} + + {% endif %} + + + + {% render_bundle 'space_manage_view' %} +{% endblock %} \ No newline at end of file diff --git a/cookbook/urls.py b/cookbook/urls.py index db3a066c..6a7a6485 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -25,6 +25,7 @@ router.register(r'food', api.FoodViewSet) router.register(r'food-inherit-field', api.FoodInheritFieldViewSet) router.register(r'import-log', api.ImportLogViewSet) router.register(r'export-log', api.ExportLogViewSet) +router.register(r'group', api.GroupViewSet) router.register(r'ingredient', api.IngredientViewSet) router.register(r'keyword', api.KeywordViewSet) router.register(r'meal-plan', api.MealPlanViewSet) @@ -35,6 +36,7 @@ router.register(r'recipe-book-entry', api.RecipeBookEntryViewSet) router.register(r'shopping-list', api.ShoppingListViewSet) router.register(r'shopping-list-entry', api.ShoppingListEntryViewSet) router.register(r'shopping-list-recipe', api.ShoppingListRecipeViewSet) +router.register(r'space', api.SpaceViewSet) router.register(r'step', api.StepViewSet) router.register(r'storage', api.StorageViewSet) router.register(r'supermarket', api.SupermarketViewSet) @@ -46,6 +48,7 @@ router.register(r'unit', api.UnitViewSet) router.register(r'user-file', api.UserFileViewSet) router.register(r'user-name', api.UserNameViewSet, basename='username') router.register(r'user-preference', api.UserPreferenceViewSet) +router.register(r'user-space', api.UserSpaceViewSet) router.register(r'view-log', api.ViewLogViewSet) urlpatterns = [ @@ -56,6 +59,7 @@ urlpatterns = [ name='change_space_member'), path('no-group', views.no_groups, name='view_no_group'), path('space-overview', views.space_overview, name='view_space_overview'), + path('space-manage/', views.space_manage, name='view_space_manage'), path('switch-space/', views.switch_space, name='view_switch_space'), path('no-perm', views.no_perm, name='view_no_perm'), path('signup/', views.signup, name='view_signup'), # TODO deprecated with 0.16.2 remove at some point diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 7f8640af..0c21294e 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -11,7 +11,7 @@ from PIL import UnidentifiedImageError from annoying.decorators import ajax_request from annoying.functions import get_object_or_None from django.contrib import messages -from django.contrib.auth.models import User +from django.contrib.auth.models import User, Group from django.contrib.postgres.search import TrigramSimilarity from django.core.exceptions import FieldError, ValidationError from django.core.files import File @@ -29,26 +29,22 @@ from requests.exceptions import MissingSchema from rest_framework import decorators, status, viewsets from rest_framework.authtoken.models import Token from rest_framework.authtoken.views import ObtainAuthToken -from rest_framework.decorators import api_view, permission_classes, schema +from rest_framework.decorators import api_view, permission_classes from rest_framework.exceptions import APIException, PermissionDenied -from rest_framework.generics import CreateAPIView from rest_framework.pagination import PageNumberPagination from rest_framework.parsers import MultiPartParser from rest_framework.renderers import JSONRenderer, TemplateHTMLRenderer from rest_framework.response import Response -from rest_framework.schemas import AutoSchema from rest_framework.throttling import AnonRateThrottle -from rest_framework.views import APIView from rest_framework.viewsets import ViewSetMixin from treebeard.exceptions import InvalidMoveToDescendant, InvalidPosition, PathOverflow -from validators import ValidationFailure from cookbook.helper.HelperFunctions import str2bool from cookbook.helper.image_processing import handle_image from cookbook.helper.ingredient_parser import IngredientParser from cookbook.helper.permission_helper import (CustomIsAdmin, CustomIsGuest, CustomIsOwner, CustomIsShare, CustomIsShared, CustomIsUser, - group_required) + group_required, CustomIsSpaceOwner) from cookbook.helper.recipe_html_import import get_recipe_from_source from cookbook.helper.recipe_search import RecipeFacet, RecipeSearch, old_search from cookbook.helper.shopping_helper import RecipeShoppingEditor, shopping_helper @@ -57,7 +53,7 @@ from cookbook.models import (Automation, BookmarkletImport, CookLog, CustomFilte Recipe, RecipeBook, RecipeBookEntry, ShareLink, ShoppingList, ShoppingListEntry, ShoppingListRecipe, Step, Storage, Supermarket, SupermarketCategory, SupermarketCategoryRelation, Sync, SyncLog, Unit, - UserFile, UserPreference, ViewLog) + UserFile, UserPreference, ViewLog, Space, UserSpace) from cookbook.provider.dropbox import Dropbox from cookbook.provider.local import Local from cookbook.provider.nextcloud import Nextcloud @@ -78,7 +74,7 @@ from cookbook.serializer import (AutomationSerializer, BookmarkletImportSerializ SupermarketCategorySerializer, SupermarketSerializer, SyncLogSerializer, SyncSerializer, UnitSerializer, UserFileSerializer, UserNameSerializer, UserPreferenceSerializer, - ViewLogSerializer, IngredientSimpleSerializer, BookmarkletImportListSerializer, RecipeFromSourceSerializer) + ViewLogSerializer, IngredientSimpleSerializer, BookmarkletImportListSerializer, RecipeFromSourceSerializer, SpaceSerializer, UserSpaceSerializer, GroupSerializer) from recipes import settings @@ -369,6 +365,33 @@ class UserNameViewSet(viewsets.ReadOnlyModelViewSet): return queryset +class GroupViewSet(viewsets.ModelViewSet): + queryset = Group.objects.all() + serializer_class = GroupSerializer + permission_classes = [CustomIsAdmin] + http_method_names = ['get', ] + + +class SpaceViewSet(viewsets.ModelViewSet): + queryset = Space.objects + serializer_class = SpaceSerializer + permission_classes = [CustomIsOwner] + http_method_names = ['get', 'patch'] + + def get_queryset(self): + return self.queryset.filter(id=self.request.space.id) + + +class UserSpaceViewSet(viewsets.ModelViewSet): + queryset = UserSpace.objects + serializer_class = UserSpaceSerializer + permission_classes = [CustomIsSpaceOwner] + http_method_names = ['get', 'patch', 'delete'] + + def get_queryset(self): + return self.queryset.filter(space=self.request.space) + + class UserPreferenceViewSet(viewsets.ModelViewSet): queryset = UserPreference.objects serializer_class = UserPreferenceSerializer diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 4a09d0d6..46c8acf4 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -26,7 +26,7 @@ from cookbook.filters import RecipeFilter from cookbook.forms import (CommentForm, Recipe, SearchPreferenceForm, ShoppingPreferenceForm, SpaceCreateForm, SpaceJoinForm, SpacePreferenceForm, User, UserCreateForm, UserNameForm, UserPreference, UserPreferenceForm) -from cookbook.helper.permission_helper import group_required, has_group_permission, share_link_valid +from cookbook.helper.permission_helper import group_required, has_group_permission, share_link_valid, switch_user_active_space from cookbook.models import (Comment, CookLog, Food, InviteLink, Keyword, MealPlan, RecipeImport, SearchFields, SearchPreference, ShareLink, Space, Unit, ViewLog, UserSpace) @@ -144,9 +144,7 @@ def space_overview(request): @login_required def switch_space(request, space_id): user_space = get_object_or_404(UserSpace, space=space_id, user=request.user) - UserSpace.objects.filter(user=request.user).update(active=False) # make sure to deactivate all spaces for a user - user_space.active = True - user_space.save() + switch_user_active_space(request.user, user_space) return HttpResponseRedirect(reverse('index')) @@ -533,6 +531,12 @@ def signup(request, token): return HttpResponseRedirect(reverse('view_invite', args=[token])) +@group_required('admin') +def space_manage(request, space_id): + user_space = get_object_or_404(UserSpace, space=space_id, user=request.user) + switch_user_active_space(request.user, user_space) + return render(request, 'space_manage.html', {}) + @group_required('admin') def space(request): space_users = UserSpace.objects.filter(space=request.space).all() diff --git a/vue/src/apps/SpaceManageView/SpaceManageView.vue b/vue/src/apps/SpaceManageView/SpaceManageView.vue new file mode 100644 index 00000000..e365829e --- /dev/null +++ b/vue/src/apps/SpaceManageView/SpaceManageView.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/vue/src/apps/SpaceManageView/main.js b/vue/src/apps/SpaceManageView/main.js new file mode 100644 index 00000000..91e5c85f --- /dev/null +++ b/vue/src/apps/SpaceManageView/main.js @@ -0,0 +1,18 @@ +import Vue from 'vue' +import App from './SpaceManageView.vue' +import i18n from '@/i18n' + +Vue.config.productionTip = false + +// TODO move this and other default stuff to centralized JS file (verify nothing breaks) +let publicPath = localStorage.STATIC_URL + 'vue/' +if (process.env.NODE_ENV === 'development') { + publicPath = 'http://localhost:8080/' +} +export default __webpack_public_path__ = publicPath // eslint-disable-line + + +new Vue({ + i18n, + render: h => h(App), +}).$mount('#app') diff --git a/vue/src/utils/models.js b/vue/src/utils/models.js index 77562b57..c1054f64 100644 --- a/vue/src/utils/models.js +++ b/vue/src/utils/models.js @@ -23,7 +23,7 @@ export class Models { false: undefined, }, }, - tree: { default: undefined }, + tree: {default: undefined}, }, }, delete: { @@ -50,7 +50,7 @@ export class Models { type: "lookup", field: "target", list: "self", - sticky_options: [{ id: 0, name: "tree_root" }], + sticky_options: [{id: 0, name: "tree_root"}], }, }, }, @@ -71,7 +71,7 @@ export class Models { food_onhand: true, shopping: true, }, - tags: [{ field: "supermarket_category", label: "name", color: "info" }], + tags: [{field: "supermarket_category", label: "name", color: "info"}], // REQUIRED: unordered array of fields that can be set during create create: { // if not defined partialUpdate will use the same parameters, prepending 'id' @@ -159,7 +159,7 @@ export class Models { field: "substitute_siblings", label: "substitute_siblings", // form.label always translated in utils.getForm() help_text: "substitute_siblings_help", // form.help_text always translated - condition: { field: "parent", value: true, condition: "field_exists" }, + condition: {field: "parent", value: true, condition: "field_exists"}, }, substitute_children: { form_field: true, @@ -168,7 +168,7 @@ export class Models { field: "substitute_children", label: "substitute_children", help_text: "substitute_children_help", - condition: { field: "numchild", value: 0, condition: "gt" }, + condition: {field: "numchild", value: 0, condition: "gt"}, }, inherit_fields: { form_field: true, @@ -178,7 +178,7 @@ export class Models { field: "inherit_fields", list: "FOOD_INHERIT_FIELDS", label: "InheritFields", - condition: { field: "food_children_exist", value: true, condition: "preference_equals" }, + condition: {field: "food_children_exist", value: true, condition: "preference_equals"}, help_text: "InheritFields_help", }, child_inherit_fields: { @@ -189,7 +189,7 @@ export class Models { field: "child_inherit_fields", list: "FOOD_INHERIT_FIELDS", label: "ChildInheritFields", // form.label always translated in utils.getForm() - condition: { field: "numchild", value: 0, condition: "gt" }, + condition: {field: "numchild", value: 0, condition: "gt"}, help_text: "ChildInheritFields_help", // form.help_text always translated }, reset_inherit: { @@ -199,7 +199,7 @@ export class Models { field: "reset_inherit", label: "reset_children", help_text: "reset_children_help", - condition: { field: "numchild", value: 0, condition: "gt" }, + condition: {field: "numchild", value: 0, condition: "gt"}, }, form_function: "FoodCreateDefault", }, @@ -399,7 +399,7 @@ export class Models { static SUPERMARKET = { name: "Supermarket", apiName: "Supermarket", - ordered_tags: [{ field: "category_to_supermarket", label: "category::name", color: "info" }], + ordered_tags: [{field: "category_to_supermarket", label: "category::name", color: "info"}], create: { params: [["name", "description", "category_to_supermarket"]], form: { @@ -469,9 +469,9 @@ export class Models { form_field: true, type: "choice", options: [ - { value: "FOOD_ALIAS", text: "Food_Alias" }, - { value: "UNIT_ALIAS", text: "Unit_Alias" }, - { value: "KEYWORD_ALIAS", text: "Keyword_Alias" }, + {value: "FOOD_ALIAS", text: "Food_Alias"}, + {value: "UNIT_ALIAS", text: "Unit_Alias"}, + {value: "KEYWORD_ALIAS", text: "Keyword_Alias"}, ], field: "type", label: "Type", @@ -669,6 +669,12 @@ export class Models { paginated: false, } + static GROUP = { + name: "Group", + apiName: "Group", + paginated: false, + } + static STEP = { name: "Step", apiName: "Step", @@ -694,7 +700,7 @@ export class Actions { }, ], }, - ok_label: { function: "translate", phrase: "Save" }, + ok_label: {function: "translate", phrase: "Save"}, }, } static UPDATE = { @@ -729,7 +735,7 @@ export class Actions { }, ], }, - ok_label: { function: "translate", phrase: "Delete" }, + ok_label: {function: "translate", phrase: "Delete"}, instruction: { form_field: true, type: "instruction", @@ -756,17 +762,17 @@ export class Actions { suffix: "s", params: ["query", "page", "pageSize", "options"], config: { - query: { default: undefined }, - page: { default: 1 }, - pageSize: { default: 25 }, + query: {default: undefined}, + page: {default: 1}, + pageSize: {default: 25}, }, } static MERGE = { function: "merge", params: ["source", "target"], config: { - source: { type: "string" }, - target: { type: "string" }, + source: {type: "string"}, + target: {type: "string"}, }, form: { title: { @@ -781,7 +787,7 @@ export class Actions { }, ], }, - ok_label: { function: "translate", phrase: "Merge" }, + ok_label: {function: "translate", phrase: "Merge"}, instruction: { form_field: true, type: "instruction", @@ -815,8 +821,8 @@ export class Actions { function: "move", params: ["source", "target"], config: { - source: { type: "string" }, - target: { type: "string" }, + source: {type: "string"}, + target: {type: "string"}, }, form: { title: { @@ -831,7 +837,7 @@ export class Actions { }, ], }, - ok_label: { function: "translate", phrase: "Move" }, + ok_label: {function: "translate", phrase: "Move"}, instruction: { form_field: true, type: "instruction", diff --git a/vue/src/utils/openapi/api.ts b/vue/src/utils/openapi/api.ts index 0ec1cee4..8fdefa94 100644 --- a/vue/src/utils/openapi/api.ts +++ b/vue/src/utils/openapi/api.ts @@ -21,6 +21,31 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; +/** + * + * @export + * @interface AuthToken + */ +export interface AuthToken { + /** + * + * @type {string} + * @memberof AuthToken + */ + username: string; + /** + * + * @type {string} + * @memberof AuthToken + */ + password: string; + /** + * + * @type {string} + * @memberof AuthToken + */ + token?: string; +} /** * * @export @@ -595,6 +620,25 @@ export interface FoodSupermarketCategory { */ description?: string | null; } +/** + * + * @export + * @interface Group + */ +export interface Group { + /** + * + * @type {number} + * @memberof Group + */ + id?: number; + /** + * + * @type {string} + * @memberof Group + */ + name: string; +} /** * * @export @@ -2866,6 +2910,103 @@ export interface ShoppingListSupermarketCategoryToSupermarket { */ order?: number; } +/** + * + * @export + * @interface Space + */ +export interface Space { + /** + * + * @type {number} + * @memberof Space + */ + id?: number; + /** + * + * @type {string} + * @memberof Space + */ + name?: string; + /** + * + * @type {string} + * @memberof Space + */ + created_by?: string | null; + /** + * + * @type {string} + * @memberof Space + */ + created_at?: string; + /** + * + * @type {string} + * @memberof Space + */ + message?: string; + /** + * + * @type {number} + * @memberof Space + */ + max_recipes?: number; + /** + * Maximum file storage for space in MB. 0 for unlimited, -1 to disable file upload. + * @type {number} + * @memberof Space + */ + max_file_storage_mb?: number; + /** + * + * @type {number} + * @memberof Space + */ + max_users?: number; + /** + * + * @type {boolean} + * @memberof Space + */ + allow_sharing?: boolean; + /** + * + * @type {boolean} + * @memberof Space + */ + demo?: boolean; + /** + * + * @type {Array} + * @memberof Space + */ + food_inherit?: Array; + /** + * + * @type {boolean} + * @memberof Space + */ + show_facet_count?: boolean; + /** + * + * @type {string} + * @memberof Space + */ + user_count?: string; + /** + * + * @type {string} + * @memberof Space + */ + recipe_count?: string; + /** + * + * @type {string} + * @memberof Space + */ + file_size_mb?: string; +} /** * * @export @@ -3467,6 +3608,49 @@ export enum UserPreferenceSearchStyleEnum { New = 'NEW' } +/** + * + * @export + * @interface UserSpace + */ +export interface UserSpace { + /** + * + * @type {number} + * @memberof UserSpace + */ + id?: number; + /** + * + * @type {ShoppingListCreatedBy} + * @memberof UserSpace + */ + user?: ShoppingListCreatedBy; + /** + * + * @type {string} + * @memberof UserSpace + */ + space?: string; + /** + * + * @type {Array} + * @memberof UserSpace + */ + groups: Array; + /** + * + * @type {string} + * @memberof UserSpace + */ + created_at?: string; + /** + * + * @type {string} + * @memberof UserSpace + */ + updated_at?: string; +} /** * * @export @@ -4418,6 +4602,39 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * function to retrieve a recipe from a given url or source string :param request: standard request with additional post parameters - url: url to use for importing recipe - data: if no url is given recipe is imported from provided source data - (optional) bookmarklet: id of bookmarklet import to use, overrides URL and data attributes :return: JsonResponse containing the parsed json, original html,json and images + * @param {any} [body] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createrecipeFromSource: async (body?: any, options: any = {}): Promise => { + const localVarPath = `/api/recipe-from-source/`; + // 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: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @param {string} id A unique integer value identifying this automation. @@ -5267,6 +5484,39 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + destroyUserSpace: async (id: string, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('destroyUserSpace', 'id', id) + const localVarPath = `/api/user-space/{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: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -5595,6 +5845,35 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listGroups: async (options: any = {}): Promise => { + const localVarPath = `/api/group/`; + // 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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6119,6 +6398,35 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listSpaces: async (options: any = {}): Promise => { + const localVarPath = `/api/space/`; + // 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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -6464,6 +6772,35 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserSpaces: async (options: any = {}): Promise => { + const localVarPath = `/api/user-space/`; + // 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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7375,6 +7712,43 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {Space} [space] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + partialUpdateSpace: async (id: string, space?: Space, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('partialUpdateSpace', 'id', id) + const localVarPath = `/api/space/{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: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(space, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @param {string} id A unique integer value identifying this step. @@ -7730,6 +8104,43 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {UserSpace} [userSpace] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + partialUpdateUserSpace: async (id: string, userSpace?: UserSpace, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('partialUpdateUserSpace', 'id', id) + const localVarPath = `/api/user-space/{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: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(userSpace, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -8022,6 +8433,39 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} id A unique integer value identifying this group. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveGroup: async (id: string, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('retrieveGroup', 'id', id) + const localVarPath = `/api/group/{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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8385,6 +8829,39 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveSpace: async (id: string, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('retrieveSpace', 'id', id) + const localVarPath = `/api/space/{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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8748,6 +9225,39 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveUserSpace: async (id: string, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('retrieveUserSpace', 'id', id) + const localVarPath = `/api/user-space/{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, options.query); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -10168,6 +10678,16 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.createViewLog(viewLog, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * function to retrieve a recipe from a given url or source string :param request: standard request with additional post parameters - url: url to use for importing recipe - data: if no url is given recipe is imported from provided source data - (optional) bookmarklet: id of bookmarklet import to use, overrides URL and data attributes :return: JsonResponse containing the parsed json, original html,json and images + * @param {any} [body] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createrecipeFromSource(body?: any, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createrecipeFromSource(body, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this automation. @@ -10428,6 +10948,16 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.destroyUserPreference(user, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async destroyUserSpace(id: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.destroyUserSpace(id, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -10522,6 +11052,15 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.listFoods(query, root, tree, page, pageSize, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listGroups(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listGroups(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {number} [page] A page number within the paginated result set. @@ -10662,6 +11201,15 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.listShoppingLists(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listSpaces(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listSpaces(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {number} [recipe] ID of recipe a step is part of. For multiple repeat parameter. @@ -10763,6 +11311,15 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.listUserPreferences(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listUserSpaces(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listUserSpaces(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * optional parameters - **filter_list**: array of user id\'s to get names for * @param {*} [options] Override http request option. @@ -11030,6 +11587,17 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateShoppingListRecipe(id, shoppingListRecipe, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {Space} [space] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async partialUpdateSpace(id: string, space?: Space, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateSpace(id, space, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this step. @@ -11132,6 +11700,17 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserPreference(user, userPreference, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {UserSpace} [userSpace] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async partialUpdateUserSpace(id: string, userSpace?: UserSpace, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserSpace(id, userSpace, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -11223,6 +11802,16 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveFoodInheritField(id, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this group. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async retrieveGroup(id: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveGroup(id, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this import log. @@ -11333,6 +11922,16 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveShoppingListRecipe(id, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async retrieveSpace(id: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveSpace(id, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this step. @@ -11443,6 +12042,16 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveUserPreference(user, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async retrieveUserSpace(id: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveUserSpace(id, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -12031,6 +12640,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: createViewLog(viewLog?: ViewLog, options?: any): AxiosPromise { return localVarFp.createViewLog(viewLog, options).then((request) => request(axios, basePath)); }, + /** + * function to retrieve a recipe from a given url or source string :param request: standard request with additional post parameters - url: url to use for importing recipe - data: if no url is given recipe is imported from provided source data - (optional) bookmarklet: id of bookmarklet import to use, overrides URL and data attributes :return: JsonResponse containing the parsed json, original html,json and images + * @param {any} [body] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createrecipeFromSource(body?: any, options?: any): AxiosPromise { + return localVarFp.createrecipeFromSource(body, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this automation. @@ -12265,6 +12883,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: destroyUserPreference(user: string, options?: any): AxiosPromise { return localVarFp.destroyUserPreference(user, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + destroyUserSpace(id: string, options?: any): AxiosPromise { + return localVarFp.destroyUserSpace(id, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -12350,6 +12977,14 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: listFoods(query?: string, root?: number, tree?: number, page?: number, pageSize?: number, options?: any): AxiosPromise { return localVarFp.listFoods(query, root, tree, page, pageSize, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listGroups(options?: any): AxiosPromise> { + return localVarFp.listGroups(options).then((request) => request(axios, basePath)); + }, /** * * @param {number} [page] A page number within the paginated result set. @@ -12479,6 +13114,14 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: listShoppingLists(options?: any): AxiosPromise> { return localVarFp.listShoppingLists(options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listSpaces(options?: any): AxiosPromise> { + return localVarFp.listSpaces(options).then((request) => request(axios, basePath)); + }, /** * * @param {number} [recipe] ID of recipe a step is part of. For multiple repeat parameter. @@ -12570,6 +13213,14 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: listUserPreferences(options?: any): AxiosPromise> { return localVarFp.listUserPreferences(options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserSpaces(options?: any): AxiosPromise> { + return localVarFp.listUserSpaces(options).then((request) => request(axios, basePath)); + }, /** * optional parameters - **filter_list**: array of user id\'s to get names for * @param {*} [options] Override http request option. @@ -12813,6 +13464,16 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: partialUpdateShoppingListRecipe(id: string, shoppingListRecipe?: ShoppingListRecipe, options?: any): AxiosPromise { return localVarFp.partialUpdateShoppingListRecipe(id, shoppingListRecipe, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {Space} [space] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + partialUpdateSpace(id: string, space?: Space, options?: any): AxiosPromise { + return localVarFp.partialUpdateSpace(id, space, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this step. @@ -12906,6 +13567,16 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: partialUpdateUserPreference(user: string, userPreference?: UserPreference, options?: any): AxiosPromise { return localVarFp.partialUpdateUserPreference(user, userPreference, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {UserSpace} [userSpace] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + partialUpdateUserSpace(id: string, userSpace?: UserSpace, options?: any): AxiosPromise { + return localVarFp.partialUpdateUserSpace(id, userSpace, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -12988,6 +13659,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: retrieveFoodInheritField(id: string, options?: any): AxiosPromise { return localVarFp.retrieveFoodInheritField(id, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this group. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveGroup(id: string, options?: any): AxiosPromise { + return localVarFp.retrieveGroup(id, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this import log. @@ -13087,6 +13767,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: retrieveShoppingListRecipe(id: string, options?: any): AxiosPromise { return localVarFp.retrieveShoppingListRecipe(id, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveSpace(id: string, options?: any): AxiosPromise { + return localVarFp.retrieveSpace(id, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this step. @@ -13186,6 +13875,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: retrieveUserPreference(user: string, options?: any): AxiosPromise { return localVarFp.retrieveUserPreference(user, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + retrieveUserSpace(id: string, options?: any): AxiosPromise { + return localVarFp.retrieveUserSpace(id, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this view log. @@ -13798,6 +14496,17 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).createViewLog(viewLog, options).then((request) => request(this.axios, this.basePath)); } + /** + * function to retrieve a recipe from a given url or source string :param request: standard request with additional post parameters - url: url to use for importing recipe - data: if no url is given recipe is imported from provided source data - (optional) bookmarklet: id of bookmarklet import to use, overrides URL and data attributes :return: JsonResponse containing the parsed json, original html,json and images + * @param {any} [body] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public createrecipeFromSource(body?: any, options?: any) { + return ApiApiFp(this.configuration).createrecipeFromSource(body, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this automation. @@ -14084,6 +14793,17 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).destroyUserPreference(user, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public destroyUserSpace(id: string, options?: any) { + return ApiApiFp(this.configuration).destroyUserSpace(id, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this view log. @@ -14187,6 +14907,16 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).listFoods(query, root, tree, page, pageSize, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public listGroups(options?: any) { + return ApiApiFp(this.configuration).listGroups(options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {number} [page] A page number within the paginated result set. @@ -14338,6 +15068,16 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).listShoppingLists(options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public listSpaces(options?: any) { + return ApiApiFp(this.configuration).listSpaces(options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {number} [recipe] ID of recipe a step is part of. For multiple repeat parameter. @@ -14449,6 +15189,16 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).listUserPreferences(options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public listUserSpaces(options?: any) { + return ApiApiFp(this.configuration).listUserSpaces(options).then((request) => request(this.axios, this.basePath)); + } + /** * optional parameters - **filter_list**: array of user id\'s to get names for * @param {*} [options] Override http request option. @@ -14740,6 +15490,18 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).partialUpdateShoppingListRecipe(id, shoppingListRecipe, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {Space} [space] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public partialUpdateSpace(id: string, space?: Space, options?: any) { + return ApiApiFp(this.configuration).partialUpdateSpace(id, space, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this step. @@ -14851,6 +15613,18 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).partialUpdateUserPreference(user, userPreference, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {UserSpace} [userSpace] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public partialUpdateUserSpace(id: string, userSpace?: UserSpace, options?: any) { + return ApiApiFp(this.configuration).partialUpdateUserSpace(id, userSpace, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this view log. @@ -14951,6 +15725,17 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).retrieveFoodInheritField(id, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this group. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public retrieveGroup(id: string, options?: any) { + return ApiApiFp(this.configuration).retrieveGroup(id, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this import log. @@ -15072,6 +15857,17 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).retrieveShoppingListRecipe(id, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public retrieveSpace(id: string, options?: any) { + return ApiApiFp(this.configuration).retrieveSpace(id, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this step. @@ -15193,6 +15989,17 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).retrieveUserPreference(user, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this user space. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public retrieveUserSpace(id: string, options?: any) { + return ApiApiFp(this.configuration).retrieveUserSpace(id, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this view log. @@ -15557,3 +16364,129 @@ export class ApiApi extends BaseAPI { } +/** + * ApiTokenAuthApi - axios parameter creator + * @export + */ +export const ApiTokenAuthApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @param {string} username + * @param {string} password + * @param {string} [token] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createAuthToken: async (username: string, password: string, token?: string, options: any = {}): Promise => { + // verify required parameter 'username' is not null or undefined + assertParamExists('createAuthToken', 'username', username) + // verify required parameter 'password' is not null or undefined + assertParamExists('createAuthToken', 'password', password) + const localVarPath = `/api-token-auth/`; + // 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: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + + if (username !== undefined) { + localVarFormParams.append('username', username as any); + } + + if (password !== undefined) { + localVarFormParams.append('password', password as any); + } + + if (token !== undefined) { + localVarFormParams.append('token', token as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * ApiTokenAuthApi - functional programming interface + * @export + */ +export const ApiTokenAuthApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = ApiTokenAuthApiAxiosParamCreator(configuration) + return { + /** + * + * @param {string} username + * @param {string} password + * @param {string} [token] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createAuthToken(username: string, password: string, token?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createAuthToken(username, password, token, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * ApiTokenAuthApi - factory interface + * @export + */ +export const ApiTokenAuthApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = ApiTokenAuthApiFp(configuration) + return { + /** + * + * @param {string} username + * @param {string} password + * @param {string} [token] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createAuthToken(username: string, password: string, token?: string, options?: any): AxiosPromise { + return localVarFp.createAuthToken(username, password, token, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * ApiTokenAuthApi - object-oriented interface + * @export + * @class ApiTokenAuthApi + * @extends {BaseAPI} + */ +export class ApiTokenAuthApi extends BaseAPI { + /** + * + * @param {string} username + * @param {string} password + * @param {string} [token] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiTokenAuthApi + */ + public createAuthToken(username: string, password: string, token?: string, options?: any) { + return ApiTokenAuthApiFp(this.configuration).createAuthToken(username, password, token, options).then((request) => request(this.axios, this.basePath)); + } +} + + diff --git a/vue/vue.config.js b/vue/vue.config.js index 6e0707a1..884bafeb 100644 --- a/vue/vue.config.js +++ b/vue/vue.config.js @@ -57,6 +57,10 @@ const pages = { entry: "./src/apps/ShoppingListView/main.js", chunks: ["chunk-vendors"], }, + space_manage_view: { + entry: "./src/apps/SpaceManageView/main.js", + chunks: ["chunk-vendors"], + }, } module.exports = {