diff --git a/api/openapi.yaml b/api/openapi.yaml index 61edbed0d..71ceb1195 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -53,6 +53,10 @@ tags: description: File uploads and downloads. - name: collections description: User curated collections of posts. + - name: clusters + description: Arbitrary item grouping pages for indexing structured content. + - name: items + description: Arbitrary item pages for indexing structured content. # # 8888888b. d8888 88888888888 888 888 .d8888b. @@ -783,6 +787,172 @@ paths: "401": { $ref: "#/components/responses/Unauthorised" } "200": { $ref: "#/components/responses/CollectionRemovePostOK" } + # + # 888 888 + # 888 888 + # 888 888 + # .d8888b 888 888 888 .d8888b 888888 .d88b. 888d888 .d8888b + # d88P" 888 888 888 88K 888 d8P Y8b 888P" 88K + # 888 888 888 888 "Y8888b. 888 88888888 888 "Y8888b. + # Y88b. 888 Y88b 888 X88 Y88b. Y8b. 888 X88 + # "Y8888P 888 "Y88888 88888P' "Y888 "Y8888 888 88888P' + # + + /v1/clusters: + post: + operationId: ClusterCreate + description: | + Create a cluster for grouping items and other clusters together. + tags: [clusters] + requestBody: { $ref: "#/components/requestBodies/ClusterCreate" } + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterCreateOK" } + get: + operationId: ClusterList + description: List all clusters. + tags: [clusters] + security: [] + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "200": { $ref: "#/components/responses/ClusterListOK" } + + /v1/clusters/{cluster_slug}: + get: + operationId: ClusterGet + description: Get a cluster by its URL slug. + tags: [clusters] + security: [] + parameters: [$ref: "#/components/parameters/ClusterSlugParam"] + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterGetOK" } + patch: + operationId: ClusterUpdate + description: Update a cluster. + tags: [clusters] + parameters: [$ref: "#/components/parameters/ClusterSlugParam"] + requestBody: { $ref: "#/components/requestBodies/ClusterUpdate" } + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterUpdateOK" } + + /v1/clusters/{cluster_slug}/clusters/{cluster_slug_child}: + put: + operationId: ClusterAddCluster + description: Set a cluster's parent to the specified cluster + tags: [clusters] + parameters: + - $ref: "#/components/parameters/ClusterSlugParam" + - $ref: "#/components/parameters/ClusterSlugChildParam" + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterAddChildOK" } + delete: + operationId: ClusterRemoveCluster + description: | + Remove a cluster from its parent cluster and back to the top level. + tags: [clusters] + parameters: + - $ref: "#/components/parameters/ClusterSlugParam" + - $ref: "#/components/parameters/ClusterSlugChildParam" + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterRemoveChildOK" } + + /v1/clusters/{cluster_slug}/items/{item_slug}: + put: + operationId: ClusterAddItem + description: Add an item to a cluster. + tags: [clusters] + parameters: + - $ref: "#/components/parameters/ClusterSlugParam" + - $ref: "#/components/parameters/ItemSlugParam" + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterAddItemOK" } + delete: + operationId: ClusterRemoveItem + description: Remove an item from a cluster. + tags: [clusters] + parameters: + - $ref: "#/components/parameters/ClusterSlugParam" + - $ref: "#/components/parameters/ItemSlugParam" + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ClusterRemoveItemOK" } + + # + # d8b 888 + # Y8P 888 + # 888 + # 888 888888 .d88b. 88888b.d88b. .d8888b + # 888 888 d8P Y8b 888 "888 "88b 88K + # 888 888 88888888 888 888 888 "Y8888b. + # 888 Y88b. Y8b. 888 888 888 X88 + # 888 "Y888 "Y8888 888 888 888 88888P' + # + + /v1/items: + post: + operationId: ItemCreate + description: | + Create a item to represent a piece of structured data such as an item in + a video game, an article of clothing, a product in a store, etc. + tags: [items] + requestBody: { $ref: "#/components/requestBodies/ItemCreate" } + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ItemCreateOK" } + get: + operationId: ItemList + description: List all items using the filtering options. + tags: [items] + security: [] + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "200": { $ref: "#/components/responses/ItemListOK" } + + /v1/items/{item_slug}: + get: + operationId: ItemGet + description: Get a item by its URL slug. + tags: [items] + security: [] + parameters: [$ref: "#/components/parameters/ItemSlugParam"] + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ItemGetOK" } + patch: + operationId: ItemUpdate + description: Update a item. + tags: [items] + parameters: [$ref: "#/components/parameters/ItemSlugParam"] + requestBody: { $ref: "#/components/requestBodies/ItemUpdate" } + responses: + default: { $ref: "#/components/responses/InternalServerError" } + "404": { $ref: "#/components/responses/NotFound" } + "401": { $ref: "#/components/responses/Unauthorised" } + "200": { $ref: "#/components/responses/ItemUpdateOK" } + components: # # 8888888b. d8888 8888888b. d8888 888b d888 8888888888 88888888888 8888888888 8888888b. .d8888b. @@ -878,6 +1048,30 @@ components: schema: $ref: "#/components/schemas/Identifier" + ClusterSlugParam: + description: Unique cluster Slug. + name: cluster_slug + in: path + required: true + schema: + $ref: "#/components/schemas/Identifier" + + ClusterSlugChildParam: + description: Unique cluster Slug. + name: cluster_slug_child + in: path + required: true + schema: + $ref: "#/components/schemas/Identifier" + + ItemSlugParam: + description: Unique cluster Slug. + name: item_slug + in: path + required: true + schema: + $ref: "#/components/schemas/Identifier" + # # 8888888b. 8888888888 .d88888b. 888 888 8888888888 .d8888b. 88888888888 .d8888b. # 888 Y88b 888 d88P" "Y88b 888 888 888 d88P Y88b 888 d88P Y88b @@ -999,6 +1193,26 @@ components: application/json: schema: { $ref: "#/components/schemas/CollectionMutableProps" } + ClusterCreate: + content: + application/json: + schema: { $ref: "#/components/schemas/ClusterInitialProps" } + + ClusterUpdate: + content: + application/json: + schema: { $ref: "#/components/schemas/ClusterMutableProps" } + + ItemCreate: + content: + application/json: + schema: { $ref: "#/components/schemas/ItemInitialProps" } + + ItemUpdate: + content: + application/json: + schema: { $ref: "#/components/schemas/ItemMutableProps" } + # # 8888888b. 8888888888 .d8888b. 8888888b. .d88888b. 888b 888 .d8888b. 8888888888 .d8888b. # 888 Y88b 888 d88P Y88b 888 Y88b d88P" "Y88b 8888b 888 d88P Y88b 888 d88P Y88b @@ -1256,6 +1470,96 @@ components: schema: $ref: "#/components/schemas/Collection" + ClusterCreateOK: + description: Cluster created. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ClusterListOK: + description: Cluster list. + content: + application/json: + schema: + type: object + required: [clusters] + properties: + clusters: { $ref: "#/components/schemas/ClusterList" } + + ClusterGetOK: + description: Cluster information and content. + content: + application/json: + schema: + $ref: "#/components/schemas/ClusterWithItems" + + ClusterUpdateOK: + description: Cluster updated. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ClusterAddChildOK: + description: Cluster child added. Returns parent cluster. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ClusterRemoveChildOK: + description: Cluster child removed. Returns parent cluster. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ClusterAddItemOK: + description: Cluster content added. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ClusterRemoveItemOK: + description: Cluster content added. + content: + application/json: + schema: + $ref: "#/components/schemas/Cluster" + + ItemCreateOK: + description: Item created. + content: + application/json: + schema: + $ref: "#/components/schemas/Item" + + ItemListOK: + description: Item list. + content: + application/json: + schema: + type: object + required: [clusters] + properties: + clusters: { $ref: "#/components/schemas/ItemList" } + + ItemGetOK: + description: Item information and content. + content: + application/json: + schema: + $ref: "#/components/schemas/ItemWithParents" + + ItemUpdateOK: + description: Item updated. + content: + application/json: + schema: + $ref: "#/components/schemas/Item" + # # .d8888b. .d8888b. 888 888 8888888888 888b d888 d8888 .d8888b. # d88P Y88b d88P Y88b 888 888 888 8888b d8888 d88888 d88P Y88b @@ -1326,6 +1630,10 @@ components: type: array items: { $ref: "#/components/schemas/ContentKind" } + Slug: + description: A URL-safe slug for uniquely identifying resources. + type: string + ThreadMark: description: | A thread's ID and optional slug separated by a dash = it's unique mark. @@ -1397,6 +1705,20 @@ components: additionalProperties: true description: Arbitrary metadata for the resource. + Properties: + description: | + Arbitrary JSON object that can express any additional data for a + resource object. This is intended for client implementations to use for + extending objects with arbitrary information to satisfy product needs. + + For example, if you were building a book database, you could use the + Properties of a cluster to specify publisher information such as date of + founding, headquarters, size, etc. and then use the Properties of the + items in that cluster to specify book information such as release date, + number of pages, etc. + type: object + additionalProperties: true + URL: description: A web address type: string @@ -2236,6 +2558,11 @@ components: type: number height: type: number + + AssetURL: + description: The URL of an asset uploaded to the platform. + type: string + # # .d8888b. 888 888 888 d8b # d88P Y88b 888 888 888 Y8P @@ -2326,6 +2653,190 @@ components: description: | A short version of the thread's body text for use in previews. + # + # .d8888b. 888 888 + # d88P Y88b 888 888 + # 888 888 888 888 + # 888 888 888 888 .d8888b 888888 .d88b. 888d888 + # 888 888 888 888 88K 888 d8P Y8b 888P" + # 888 888 888 888 888 "Y8888b. 888 88888888 888 + # Y88b d88P 888 Y88b 888 X88 Y88b. Y8b. 888 + # "Y8888P" 888 "Y88888 88888P' "Y888 "Y8888 888 + # + + Cluster: + description: | + A cluster is a group of items and other clusters. It serves as an + abstraction for grouping structured data objects. It can represent + things such as brands, manufacturers, authors, directors, etc. Clusters + can be referenced in content posts and they also have their own content. + type: object + allOf: + - $ref: "#/components/schemas/CommonProperties" + - $ref: "#/components/schemas/ClusterCommonProps" + + ClusterWithItems: + description: | + The full properties of a cluster including all items and maybe child + clusters (depending on what the endpoint is configured or queried to do) + for rendering a single cluster on a view. + type: object + required: [items] + allOf: + - $ref: "#/components/schemas/Cluster" + - required: [items, clusters] + properties: + items: { $ref: "#/components/schemas/ClusterItemList" } + clusters: { $ref: "#/components/schemas/ClusterList" } + + ClusterName: + type: string + + ClusterSlug: + $ref: "#/components/schemas/Slug" + + ClusterDescription: + type: string + + ClusterCommonProps: + description: The main properties of a cluster. + type: object + required: [name, slug, description, owner] + properties: + name: { $ref: "#/components/schemas/ClusterName" } + slug: { $ref: "#/components/schemas/ClusterSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ClusterDescription" } + owner: { $ref: "#/components/schemas/ProfileReference" } + properties: { $ref: "#/components/schemas/Properties" } + + ClusterList: + type: array + items: { $ref: "#/components/schemas/Cluster" } + + ClusterInitialProps: + type: object + required: [name, slug, description] + properties: + name: { $ref: "#/components/schemas/ClusterName" } + slug: { $ref: "#/components/schemas/ClusterSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ClusterDescription" } + properties: { $ref: "#/components/schemas/Properties" } + + ClusterMutableProps: + description: | + Note: Properties are replace-all and are not merged with existing. + type: object + properties: + name: { $ref: "#/components/schemas/ClusterName" } + slug: { $ref: "#/components/schemas/ClusterSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ClusterDescription" } + properties: { $ref: "#/components/schemas/Properties" } + + ClusterItemList: + description: | + A list of items within the context of belonging to a cluster. Different + from an ItemList because we do not need to include the parent cluster + information inside each item since it's already available. + type: array + items: { $ref: "#/components/schemas/ClusterItem" } + + ClusterItem: + description: | + An item belonging to the enclosing cluster. + allOf: + - $ref: "#/components/schemas/Item" + + # + # 8888888 888 + # 888 888 + # 888 888 + # 888 888888 .d88b. 88888b.d88b. + # 888 888 d8P Y8b 888 "888 "88b + # 888 888 88888888 888 888 888 + # 888 Y88b. Y8b. 888 888 888 + # 8888888 "Y888 "Y8888 888 888 888 + # + + Item: + description: | + An item is an arbitrary object used for indexing any kind of structured + data for the purposes of archival, search, documentation, products, etc. + Items are similar to posts in terms of data model but are semantically + different when it comes to purpose. + + If you were to use Storyden to run a community for a video game for + example, items could be used to represent actual items from the game + which allows members to search for them as well as reference them in + posts and other content. + type: object + allOf: + - $ref: "#/components/schemas/CommonProperties" + - $ref: "#/components/schemas/ItemCommonProps" + + ItemName: + type: string + + ItemSlug: + $ref: "#/components/schemas/Slug" + + ItemDescription: + type: string + + ItemCommonProps: + description: The main properties for an item. + type: object + required: [name, slug, description, owner] + properties: + name: { $ref: "#/components/schemas/ItemName" } + slug: { $ref: "#/components/schemas/ItemSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ItemDescription" } + owner: { $ref: "#/components/schemas/ProfileReference" } + properties: { $ref: "#/components/schemas/Properties" } + + ItemWithParents: + description: | + Represents an item with the parent cluster information included. Used by + schemas that only want a single item along with its cluster information. + type: object + allOf: + - $ref: "#/components/schemas/CommonProperties" + - $ref: "#/components/schemas/ItemCommonProps" + - properties: + clusters: { $ref: "#/components/schemas/ClusterList" } + + ItemList: + description: | + A list of items where each item includes all the information about its + parent cluster too. For use with APIs that want to provide a list of + items that may be part of different clusters. + type: array + items: { $ref: "#/components/schemas/ItemWithParents" } + + ItemInitialProps: + type: object + required: [name, slug, description] + properties: + name: { $ref: "#/components/schemas/ItemName" } + slug: { $ref: "#/components/schemas/ItemSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ItemDescription" } + properties: { $ref: "#/components/schemas/Properties" } + + ItemMutableProps: + description: | + Note: Properties are replace-all and are not merged with existing. + type: object + properties: + name: { $ref: "#/components/schemas/ItemName" } + slug: { $ref: "#/components/schemas/ItemSlug" } + image_url: { $ref: "#/components/schemas/AssetURL" } + description: { $ref: "#/components/schemas/ItemDescription" } + properties: { $ref: "#/components/schemas/Properties" } + securitySchemes: browser: type: apiKey diff --git a/app/transports/openapi/bindings/bindings.go b/app/transports/openapi/bindings/bindings.go index 0fdf7c74d..657e04c97 100644 --- a/app/transports/openapi/bindings/bindings.go +++ b/app/transports/openapi/bindings/bindings.go @@ -75,6 +75,8 @@ type Bindings struct { Reacts Assets Collections + Clusters + Items } // bindingsProviders provides to the application the necessary implementations @@ -97,6 +99,8 @@ func bindingsProviders() fx.Option { NewReacts, NewAssets, NewCollections, + NewClusters, + NewItems, ) } diff --git a/app/transports/openapi/bindings/clusters.go b/app/transports/openapi/bindings/clusters.go new file mode 100644 index 000000000..29dafe0af --- /dev/null +++ b/app/transports/openapi/bindings/clusters.go @@ -0,0 +1,56 @@ +package bindings + +import ( + "context" + + "github.com/Southclaws/storyden/app/resources/collection" + collection_svc "github.com/Southclaws/storyden/app/services/collection" + "github.com/Southclaws/storyden/internal/openapi" +) + +type Clusters struct { + collection_repo collection.Repository + collection_svc collection_svc.Service +} + +func NewClusters( + collection_repo collection.Repository, + collection_svc collection_svc.Service, +) Clusters { + return Clusters{ + collection_repo: collection_repo, + collection_svc: collection_svc, + } +} + +func (i *Clusters) ClusterList(ctx context.Context, request openapi.ClusterListRequestObject) (openapi.ClusterListResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterCreate(ctx context.Context, request openapi.ClusterCreateRequestObject) (openapi.ClusterCreateResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterGet(ctx context.Context, request openapi.ClusterGetRequestObject) (openapi.ClusterGetResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterUpdate(ctx context.Context, request openapi.ClusterUpdateRequestObject) (openapi.ClusterUpdateResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterRemoveCluster(ctx context.Context, request openapi.ClusterRemoveClusterRequestObject) (openapi.ClusterRemoveClusterResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterAddCluster(ctx context.Context, request openapi.ClusterAddClusterRequestObject) (openapi.ClusterAddClusterResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterRemoveItem(ctx context.Context, request openapi.ClusterRemoveItemRequestObject) (openapi.ClusterRemoveItemResponseObject, error) { + return nil, nil +} + +func (i *Clusters) ClusterAddItem(ctx context.Context, request openapi.ClusterAddItemRequestObject) (openapi.ClusterAddItemResponseObject, error) { + return nil, nil +} diff --git a/app/transports/openapi/bindings/items.go b/app/transports/openapi/bindings/items.go new file mode 100644 index 000000000..47bf27bcb --- /dev/null +++ b/app/transports/openapi/bindings/items.go @@ -0,0 +1,40 @@ +package bindings + +import ( + "context" + + "github.com/Southclaws/storyden/app/resources/collection" + collection_svc "github.com/Southclaws/storyden/app/services/collection" + "github.com/Southclaws/storyden/internal/openapi" +) + +type Items struct { + collection_repo collection.Repository + collection_svc collection_svc.Service +} + +func NewItems( + collection_repo collection.Repository, + collection_svc collection_svc.Service, +) Items { + return Items{ + collection_repo: collection_repo, + collection_svc: collection_svc, + } +} + +func (i *Items) ItemList(ctx context.Context, request openapi.ItemListRequestObject) (openapi.ItemListResponseObject, error) { + return nil, nil +} + +func (i *Items) ItemCreate(ctx context.Context, request openapi.ItemCreateRequestObject) (openapi.ItemCreateResponseObject, error) { + return nil, nil +} + +func (i *Items) ItemGet(ctx context.Context, request openapi.ItemGetRequestObject) (openapi.ItemGetResponseObject, error) { + return nil, nil +} + +func (i *Items) ItemUpdate(ctx context.Context, request openapi.ItemUpdateRequestObject) (openapi.ItemUpdateResponseObject, error) { + return nil, nil +} diff --git a/go.mod b/go.mod index 100f72d03..d4d69ec6f 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,7 @@ require github.com/Southclaws/fault v0.6.0 require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/Southclaws/opt v0.6.0 + github.com/a8m/enter v0.0.0-20230407172335-1834787a98fe github.com/dboslee/lru v0.0.1 github.com/disintegration/imaging v1.6.2 github.com/gabriel-vasile/mimetype v1.4.2 diff --git a/go.sum b/go.sum index 95910e731..719cfd775 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/Southclaws/fault v0.6.0 h1:DioPOnLB0rXH80eca65BmO6UTaemz0XwN0Lws4G3Kg github.com/Southclaws/fault v0.6.0/go.mod h1:ykAz97glbxwopwRqAPfQMy8/Y4O+s3c6YtXwaSbxnEg= github.com/Southclaws/opt v0.6.0 h1:DnsHXMfeW8vV1y2oa26bpx1dn76PERw4QNw25b6U498= github.com/Southclaws/opt v0.6.0/go.mod h1:zGjXSHmM4ScFX3TLkCr8TdVvd4KAcZq0mwWtzqoqwwQ= +github.com/a8m/enter v0.0.0-20230407172335-1834787a98fe h1:Wx1QNWtwtyIOMCJ+zQ6NkweM+TB+DbNcoz56HibaBtI= +github.com/a8m/enter v0.0.0-20230407172335-1834787a98fe/go.mod h1:oIhrOH1HOtDThKUKzKLbeF979y2PjDTiLPSTe4kmTDE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= diff --git a/internal/ent/account.go b/internal/ent/account.go index 7dac83f31..396f200a4 100644 --- a/internal/ent/account.go +++ b/internal/ent/account.go @@ -50,11 +50,15 @@ type AccountEdges struct { Tags []*Tag `json:"tags,omitempty"` // Collections holds the value of the collections edge. Collections []*Collection `json:"collections,omitempty"` + // Clusters holds the value of the clusters edge. + Clusters []*Cluster `json:"clusters,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` // Assets holds the value of the assets edge. Assets []*Asset `json:"assets,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [7]bool + loadedTypes [9]bool } // PostsOrErr returns the Posts value or an error if the edge @@ -111,10 +115,28 @@ func (e AccountEdges) CollectionsOrErr() ([]*Collection, error) { return nil, &NotLoadedError{edge: "collections"} } +// ClustersOrErr returns the Clusters value or an error if the edge +// was not loaded in eager-loading. +func (e AccountEdges) ClustersOrErr() ([]*Cluster, error) { + if e.loadedTypes[6] { + return e.Clusters, nil + } + return nil, &NotLoadedError{edge: "clusters"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e AccountEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[7] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} +} + // AssetsOrErr returns the Assets value or an error if the edge // was not loaded in eager-loading. func (e AccountEdges) AssetsOrErr() ([]*Asset, error) { - if e.loadedTypes[6] { + if e.loadedTypes[8] { return e.Assets, nil } return nil, &NotLoadedError{edge: "assets"} @@ -232,6 +254,16 @@ func (a *Account) QueryCollections() *CollectionQuery { return NewAccountClient(a.config).QueryCollections(a) } +// QueryClusters queries the "clusters" edge of the Account entity. +func (a *Account) QueryClusters() *ClusterQuery { + return NewAccountClient(a.config).QueryClusters(a) +} + +// QueryItems queries the "items" edge of the Account entity. +func (a *Account) QueryItems() *ItemQuery { + return NewAccountClient(a.config).QueryItems(a) +} + // QueryAssets queries the "assets" edge of the Account entity. func (a *Account) QueryAssets() *AssetQuery { return NewAccountClient(a.config).QueryAssets(a) diff --git a/internal/ent/account/account.go b/internal/ent/account/account.go index a113deeb4..db89d3b0a 100644 --- a/internal/ent/account/account.go +++ b/internal/ent/account/account.go @@ -39,6 +39,10 @@ const ( EdgeTags = "tags" // EdgeCollections holds the string denoting the collections edge name in mutations. EdgeCollections = "collections" + // EdgeClusters holds the string denoting the clusters edge name in mutations. + EdgeClusters = "clusters" + // EdgeItems holds the string denoting the items edge name in mutations. + EdgeItems = "items" // EdgeAssets holds the string denoting the assets edge name in mutations. EdgeAssets = "assets" // Table holds the table name of the account in the database. @@ -81,6 +85,20 @@ const ( CollectionsInverseTable = "collections" // CollectionsColumn is the table column denoting the collections relation/edge. CollectionsColumn = "account_collections" + // ClustersTable is the table that holds the clusters relation/edge. + ClustersTable = "clusters" + // ClustersInverseTable is the table name for the Cluster entity. + // It exists in this package in order to avoid circular dependency with the "cluster" package. + ClustersInverseTable = "clusters" + // ClustersColumn is the table column denoting the clusters relation/edge. + ClustersColumn = "account_id" + // ItemsTable is the table that holds the items relation/edge. + ItemsTable = "items" + // ItemsInverseTable is the table name for the Item entity. + // It exists in this package in order to avoid circular dependency with the "item" package. + ItemsInverseTable = "items" + // ItemsColumn is the table column denoting the items relation/edge. + ItemsColumn = "account_id" // AssetsTable is the table that holds the assets relation/edge. AssetsTable = "assets" // AssetsInverseTable is the table name for the Asset entity. diff --git a/internal/ent/account/where.go b/internal/ent/account/where.go index 46a8a4b6f..71b8b40b9 100644 --- a/internal/ent/account/where.go +++ b/internal/ent/account/where.go @@ -598,6 +598,60 @@ func HasCollectionsWith(preds ...predicate.Collection) predicate.Account { }) } +// HasClusters applies the HasEdge predicate on the "clusters" edge. +func HasClusters() predicate.Account { + return predicate.Account(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ClustersTable, ClustersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasClustersWith applies the HasEdge predicate on the "clusters" edge with a given conditions (other predicates). +func HasClustersWith(preds ...predicate.Cluster) predicate.Account { + return predicate.Account(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ClustersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ClustersTable, ClustersColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasItems applies the HasEdge predicate on the "items" edge. +func HasItems() predicate.Account { + return predicate.Account(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). +func HasItemsWith(preds ...predicate.Item) predicate.Account { + return predicate.Account(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasAssets applies the HasEdge predicate on the "assets" edge. func HasAssets() predicate.Account { return predicate.Account(func(s *sql.Selector) { diff --git a/internal/ent/account_create.go b/internal/ent/account_create.go index 0947f127d..75a64359e 100644 --- a/internal/ent/account_create.go +++ b/internal/ent/account_create.go @@ -15,7 +15,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/react" "github.com/Southclaws/storyden/internal/ent/role" @@ -217,6 +219,36 @@ func (ac *AccountCreate) AddCollections(c ...*Collection) *AccountCreate { return ac.AddCollectionIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (ac *AccountCreate) AddClusterIDs(ids ...xid.ID) *AccountCreate { + ac.mutation.AddClusterIDs(ids...) + return ac +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (ac *AccountCreate) AddClusters(c ...*Cluster) *AccountCreate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return ac.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (ac *AccountCreate) AddItemIDs(ids ...xid.ID) *AccountCreate { + ac.mutation.AddItemIDs(ids...) + return ac +} + +// AddItems adds the "items" edges to the Item entity. +func (ac *AccountCreate) AddItems(i ...*Item) *AccountCreate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return ac.AddItemIDs(ids...) +} + // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (ac *AccountCreate) AddAssetIDs(ids ...string) *AccountCreate { ac.mutation.AddAssetIDs(ids...) @@ -477,6 +509,38 @@ func (ac *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := ac.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ac.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := ac.mutation.AssetsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/account_query.go b/internal/ent/account_query.go index beba4e9de..a8dbdc632 100644 --- a/internal/ent/account_query.go +++ b/internal/ent/account_query.go @@ -14,7 +14,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/Southclaws/storyden/internal/ent/react" @@ -36,6 +38,8 @@ type AccountQuery struct { withAuthentication *AuthenticationQuery withTags *TagQuery withCollections *CollectionQuery + withClusters *ClusterQuery + withItems *ItemQuery withAssets *AssetQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). @@ -206,6 +210,50 @@ func (aq *AccountQuery) QueryCollections() *CollectionQuery { return query } +// QueryClusters chains the current query on the "clusters" edge. +func (aq *AccountQuery) QueryClusters() *ClusterQuery { + query := (&ClusterClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(account.Table, account.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, account.ClustersTable, account.ClustersColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (aq *AccountQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(account.Table, account.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, account.ItemsTable, account.ItemsColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryAssets chains the current query on the "assets" edge. func (aq *AccountQuery) QueryAssets() *AssetQuery { query := (&AssetClient{config: aq.config}).Query() @@ -426,6 +474,8 @@ func (aq *AccountQuery) Clone() *AccountQuery { withAuthentication: aq.withAuthentication.Clone(), withTags: aq.withTags.Clone(), withCollections: aq.withCollections.Clone(), + withClusters: aq.withClusters.Clone(), + withItems: aq.withItems.Clone(), withAssets: aq.withAssets.Clone(), // clone intermediate query. sql: aq.sql.Clone(), @@ -499,6 +549,28 @@ func (aq *AccountQuery) WithCollections(opts ...func(*CollectionQuery)) *Account return aq } +// WithClusters tells the query-builder to eager-load the nodes that are connected to +// the "clusters" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AccountQuery) WithClusters(opts ...func(*ClusterQuery)) *AccountQuery { + query := (&ClusterClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withClusters = query + return aq +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AccountQuery) WithItems(opts ...func(*ItemQuery)) *AccountQuery { + query := (&ItemClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withItems = query + return aq +} + // WithAssets tells the query-builder to eager-load the nodes that are connected to // the "assets" edge. The optional arguments are used to configure the query builder of the edge. func (aq *AccountQuery) WithAssets(opts ...func(*AssetQuery)) *AccountQuery { @@ -588,13 +660,15 @@ func (aq *AccountQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Acco var ( nodes = []*Account{} _spec = aq.querySpec() - loadedTypes = [7]bool{ + loadedTypes = [9]bool{ aq.withPosts != nil, aq.withReacts != nil, aq.withRoles != nil, aq.withAuthentication != nil, aq.withTags != nil, aq.withCollections != nil, + aq.withClusters != nil, + aq.withItems != nil, aq.withAssets != nil, } ) @@ -661,6 +735,20 @@ func (aq *AccountQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Acco return nil, err } } + if query := aq.withClusters; query != nil { + if err := aq.loadClusters(ctx, query, nodes, + func(n *Account) { n.Edges.Clusters = []*Cluster{} }, + func(n *Account, e *Cluster) { n.Edges.Clusters = append(n.Edges.Clusters, e) }); err != nil { + return nil, err + } + } + if query := aq.withItems; query != nil { + if err := aq.loadItems(ctx, query, nodes, + func(n *Account) { n.Edges.Items = []*Item{} }, + func(n *Account, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + return nil, err + } + } if query := aq.withAssets; query != nil { if err := aq.loadAssets(ctx, query, nodes, func(n *Account) { n.Edges.Assets = []*Asset{} }, @@ -913,6 +1001,60 @@ func (aq *AccountQuery) loadCollections(ctx context.Context, query *CollectionQu } return nil } +func (aq *AccountQuery) loadClusters(ctx context.Context, query *ClusterQuery, nodes []*Account, init func(*Account), assign func(*Account, *Cluster)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[xid.ID]*Account) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.Where(predicate.Cluster(func(s *sql.Selector) { + s.Where(sql.InValues(account.ClustersColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.AccountID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "account_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (aq *AccountQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Account, init func(*Account), assign func(*Account, *Item)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[xid.ID]*Account) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.Where(predicate.Item(func(s *sql.Selector) { + s.Where(sql.InValues(account.ItemsColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.AccountID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "account_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (aq *AccountQuery) loadAssets(ctx context.Context, query *AssetQuery, nodes []*Account, init func(*Account), assign func(*Account, *Asset)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[xid.ID]*Account) diff --git a/internal/ent/account_update.go b/internal/ent/account_update.go index c4a3d9ac1..a1d42e30b 100644 --- a/internal/ent/account_update.go +++ b/internal/ent/account_update.go @@ -14,7 +14,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/Southclaws/storyden/internal/ent/react" @@ -199,6 +201,36 @@ func (au *AccountUpdate) AddCollections(c ...*Collection) *AccountUpdate { return au.AddCollectionIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (au *AccountUpdate) AddClusterIDs(ids ...xid.ID) *AccountUpdate { + au.mutation.AddClusterIDs(ids...) + return au +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (au *AccountUpdate) AddClusters(c ...*Cluster) *AccountUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return au.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (au *AccountUpdate) AddItemIDs(ids ...xid.ID) *AccountUpdate { + au.mutation.AddItemIDs(ids...) + return au +} + +// AddItems adds the "items" edges to the Item entity. +func (au *AccountUpdate) AddItems(i ...*Item) *AccountUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return au.AddItemIDs(ids...) +} + // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (au *AccountUpdate) AddAssetIDs(ids ...string) *AccountUpdate { au.mutation.AddAssetIDs(ids...) @@ -345,6 +377,48 @@ func (au *AccountUpdate) RemoveCollections(c ...*Collection) *AccountUpdate { return au.RemoveCollectionIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (au *AccountUpdate) ClearClusters() *AccountUpdate { + au.mutation.ClearClusters() + return au +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (au *AccountUpdate) RemoveClusterIDs(ids ...xid.ID) *AccountUpdate { + au.mutation.RemoveClusterIDs(ids...) + return au +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (au *AccountUpdate) RemoveClusters(c ...*Cluster) *AccountUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return au.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (au *AccountUpdate) ClearItems() *AccountUpdate { + au.mutation.ClearItems() + return au +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (au *AccountUpdate) RemoveItemIDs(ids ...xid.ID) *AccountUpdate { + au.mutation.RemoveItemIDs(ids...) + return au +} + +// RemoveItems removes "items" edges to Item entities. +func (au *AccountUpdate) RemoveItems(i ...*Item) *AccountUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return au.RemoveItemIDs(ids...) +} + // ClearAssets clears all "assets" edges to the Asset entity. func (au *AccountUpdate) ClearAssets() *AccountUpdate { au.mutation.ClearAssets() @@ -729,6 +803,96 @@ func (au *AccountUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if au.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedClustersIDs(); len(nodes) > 0 && !au.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if au.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedItemsIDs(); len(nodes) > 0 && !au.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if au.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -958,6 +1122,36 @@ func (auo *AccountUpdateOne) AddCollections(c ...*Collection) *AccountUpdateOne return auo.AddCollectionIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (auo *AccountUpdateOne) AddClusterIDs(ids ...xid.ID) *AccountUpdateOne { + auo.mutation.AddClusterIDs(ids...) + return auo +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (auo *AccountUpdateOne) AddClusters(c ...*Cluster) *AccountUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return auo.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (auo *AccountUpdateOne) AddItemIDs(ids ...xid.ID) *AccountUpdateOne { + auo.mutation.AddItemIDs(ids...) + return auo +} + +// AddItems adds the "items" edges to the Item entity. +func (auo *AccountUpdateOne) AddItems(i ...*Item) *AccountUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return auo.AddItemIDs(ids...) +} + // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (auo *AccountUpdateOne) AddAssetIDs(ids ...string) *AccountUpdateOne { auo.mutation.AddAssetIDs(ids...) @@ -1104,6 +1298,48 @@ func (auo *AccountUpdateOne) RemoveCollections(c ...*Collection) *AccountUpdateO return auo.RemoveCollectionIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (auo *AccountUpdateOne) ClearClusters() *AccountUpdateOne { + auo.mutation.ClearClusters() + return auo +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (auo *AccountUpdateOne) RemoveClusterIDs(ids ...xid.ID) *AccountUpdateOne { + auo.mutation.RemoveClusterIDs(ids...) + return auo +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (auo *AccountUpdateOne) RemoveClusters(c ...*Cluster) *AccountUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return auo.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (auo *AccountUpdateOne) ClearItems() *AccountUpdateOne { + auo.mutation.ClearItems() + return auo +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (auo *AccountUpdateOne) RemoveItemIDs(ids ...xid.ID) *AccountUpdateOne { + auo.mutation.RemoveItemIDs(ids...) + return auo +} + +// RemoveItems removes "items" edges to Item entities. +func (auo *AccountUpdateOne) RemoveItems(i ...*Item) *AccountUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return auo.RemoveItemIDs(ids...) +} + // ClearAssets clears all "assets" edges to the Asset entity. func (auo *AccountUpdateOne) ClearAssets() *AccountUpdateOne { auo.mutation.ClearAssets() @@ -1518,6 +1754,96 @@ func (auo *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err e } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if auo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedClustersIDs(); len(nodes) > 0 && !auo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ClustersTable, + Columns: []string{account.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if auo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedItemsIDs(); len(nodes) > 0 && !auo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: account.ItemsTable, + Columns: []string{account.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if auo.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/ent/asset.go b/internal/ent/asset.go index 221f6b998..0b8dfffd1 100644 --- a/internal/ent/asset.go +++ b/internal/ent/asset.go @@ -41,11 +41,15 @@ type Asset struct { type AssetEdges struct { // Posts holds the value of the posts edge. Posts []*Post `json:"posts,omitempty"` + // Clusters holds the value of the clusters edge. + Clusters []*Cluster `json:"clusters,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` // Owner holds the value of the owner edge. Owner *Account `json:"owner,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [4]bool } // PostsOrErr returns the Posts value or an error if the edge @@ -57,10 +61,28 @@ func (e AssetEdges) PostsOrErr() ([]*Post, error) { return nil, &NotLoadedError{edge: "posts"} } +// ClustersOrErr returns the Clusters value or an error if the edge +// was not loaded in eager-loading. +func (e AssetEdges) ClustersOrErr() ([]*Cluster, error) { + if e.loadedTypes[1] { + return e.Clusters, nil + } + return nil, &NotLoadedError{edge: "clusters"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e AssetEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[2] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} +} + // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AssetEdges) OwnerOrErr() (*Account, error) { - if e.loadedTypes[1] { + if e.loadedTypes[3] { if e.Owner == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: account.Label} @@ -156,6 +178,16 @@ func (a *Asset) QueryPosts() *PostQuery { return NewAssetClient(a.config).QueryPosts(a) } +// QueryClusters queries the "clusters" edge of the Asset entity. +func (a *Asset) QueryClusters() *ClusterQuery { + return NewAssetClient(a.config).QueryClusters(a) +} + +// QueryItems queries the "items" edge of the Asset entity. +func (a *Asset) QueryItems() *ItemQuery { + return NewAssetClient(a.config).QueryItems(a) +} + // QueryOwner queries the "owner" edge of the Asset entity. func (a *Asset) QueryOwner() *AccountQuery { return NewAssetClient(a.config).QueryOwner(a) diff --git a/internal/ent/asset/asset.go b/internal/ent/asset/asset.go index 28686b514..a97dbcb24 100644 --- a/internal/ent/asset/asset.go +++ b/internal/ent/asset/asset.go @@ -27,6 +27,10 @@ const ( FieldAccountID = "account_id" // EdgePosts holds the string denoting the posts edge name in mutations. EdgePosts = "posts" + // EdgeClusters holds the string denoting the clusters edge name in mutations. + EdgeClusters = "clusters" + // EdgeItems holds the string denoting the items edge name in mutations. + EdgeItems = "items" // EdgeOwner holds the string denoting the owner edge name in mutations. EdgeOwner = "owner" // Table holds the table name of the asset in the database. @@ -36,6 +40,16 @@ const ( // PostsInverseTable is the table name for the Post entity. // It exists in this package in order to avoid circular dependency with the "post" package. PostsInverseTable = "posts" + // ClustersTable is the table that holds the clusters relation/edge. The primary key declared below. + ClustersTable = "cluster_assets" + // ClustersInverseTable is the table name for the Cluster entity. + // It exists in this package in order to avoid circular dependency with the "cluster" package. + ClustersInverseTable = "clusters" + // ItemsTable is the table that holds the items relation/edge. The primary key declared below. + ItemsTable = "item_assets" + // ItemsInverseTable is the table name for the Item entity. + // It exists in this package in order to avoid circular dependency with the "item" package. + ItemsInverseTable = "items" // OwnerTable is the table that holds the owner relation/edge. OwnerTable = "assets" // OwnerInverseTable is the table name for the Account entity. @@ -61,6 +75,12 @@ var ( // PostsPrimaryKey and PostsColumn2 are the table columns denoting the // primary key for the posts relation (M2M). PostsPrimaryKey = []string{"post_id", "asset_id"} + // ClustersPrimaryKey and ClustersColumn2 are the table columns denoting the + // primary key for the clusters relation (M2M). + ClustersPrimaryKey = []string{"cluster_id", "asset_id"} + // ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the + // primary key for the items relation (M2M). + ItemsPrimaryKey = []string{"item_id", "asset_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/internal/ent/asset/where.go b/internal/ent/asset/where.go index 496fbe12f..254d69cb0 100644 --- a/internal/ent/asset/where.go +++ b/internal/ent/asset/where.go @@ -488,6 +488,60 @@ func HasPostsWith(preds ...predicate.Post) predicate.Asset { }) } +// HasClusters applies the HasEdge predicate on the "clusters" edge. +func HasClusters() predicate.Asset { + return predicate.Asset(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasClustersWith applies the HasEdge predicate on the "clusters" edge with a given conditions (other predicates). +func HasClustersWith(preds ...predicate.Cluster) predicate.Asset { + return predicate.Asset(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ClustersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasItems applies the HasEdge predicate on the "items" edge. +func HasItems() predicate.Asset { + return predicate.Asset(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). +func HasItemsWith(preds ...predicate.Item) predicate.Asset { + return predicate.Asset(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasOwner applies the HasEdge predicate on the "owner" edge. func HasOwner() predicate.Asset { return predicate.Asset(func(s *sql.Selector) { diff --git a/internal/ent/asset_create.go b/internal/ent/asset_create.go index bace799c4..ef9ea5d1b 100644 --- a/internal/ent/asset_create.go +++ b/internal/ent/asset_create.go @@ -14,6 +14,8 @@ import ( "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/rs/xid" ) @@ -105,6 +107,36 @@ func (ac *AssetCreate) AddPosts(p ...*Post) *AssetCreate { return ac.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (ac *AssetCreate) AddClusterIDs(ids ...xid.ID) *AssetCreate { + ac.mutation.AddClusterIDs(ids...) + return ac +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (ac *AssetCreate) AddClusters(c ...*Cluster) *AssetCreate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return ac.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (ac *AssetCreate) AddItemIDs(ids ...xid.ID) *AssetCreate { + ac.mutation.AddItemIDs(ids...) + return ac +} + +// AddItems adds the "items" edges to the Item entity. +func (ac *AssetCreate) AddItems(i ...*Item) *AssetCreate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return ac.AddItemIDs(ids...) +} + // SetOwnerID sets the "owner" edge to the Account entity by ID. func (ac *AssetCreate) SetOwnerID(id xid.ID) *AssetCreate { ac.mutation.SetOwnerID(id) @@ -268,6 +300,38 @@ func (ac *AssetCreate) createSpec() (*Asset, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := ac.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ac.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := ac.mutation.OwnerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/ent/asset_query.go b/internal/ent/asset_query.go index d0b6a84fc..cae499a8e 100644 --- a/internal/ent/asset_query.go +++ b/internal/ent/asset_query.go @@ -13,6 +13,8 @@ import ( "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/rs/xid" @@ -21,13 +23,15 @@ import ( // AssetQuery is the builder for querying Asset entities. type AssetQuery struct { config - ctx *QueryContext - order []OrderFunc - inters []Interceptor - predicates []predicate.Asset - withPosts *PostQuery - withOwner *AccountQuery - modifiers []func(*sql.Selector) + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Asset + withPosts *PostQuery + withClusters *ClusterQuery + withItems *ItemQuery + withOwner *AccountQuery + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -86,6 +90,50 @@ func (aq *AssetQuery) QueryPosts() *PostQuery { return query } +// QueryClusters chains the current query on the "clusters" edge. +func (aq *AssetQuery) QueryClusters() *ClusterQuery { + query := (&ClusterClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(asset.Table, asset.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, asset.ClustersTable, asset.ClustersPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (aq *AssetQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(asset.Table, asset.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, asset.ItemsTable, asset.ItemsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryOwner chains the current query on the "owner" edge. func (aq *AssetQuery) QueryOwner() *AccountQuery { query := (&AccountClient{config: aq.config}).Query() @@ -295,13 +343,15 @@ func (aq *AssetQuery) Clone() *AssetQuery { return nil } return &AssetQuery{ - config: aq.config, - ctx: aq.ctx.Clone(), - order: append([]OrderFunc{}, aq.order...), - inters: append([]Interceptor{}, aq.inters...), - predicates: append([]predicate.Asset{}, aq.predicates...), - withPosts: aq.withPosts.Clone(), - withOwner: aq.withOwner.Clone(), + config: aq.config, + ctx: aq.ctx.Clone(), + order: append([]OrderFunc{}, aq.order...), + inters: append([]Interceptor{}, aq.inters...), + predicates: append([]predicate.Asset{}, aq.predicates...), + withPosts: aq.withPosts.Clone(), + withClusters: aq.withClusters.Clone(), + withItems: aq.withItems.Clone(), + withOwner: aq.withOwner.Clone(), // clone intermediate query. sql: aq.sql.Clone(), path: aq.path, @@ -319,6 +369,28 @@ func (aq *AssetQuery) WithPosts(opts ...func(*PostQuery)) *AssetQuery { return aq } +// WithClusters tells the query-builder to eager-load the nodes that are connected to +// the "clusters" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AssetQuery) WithClusters(opts ...func(*ClusterQuery)) *AssetQuery { + query := (&ClusterClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withClusters = query + return aq +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AssetQuery) WithItems(opts ...func(*ItemQuery)) *AssetQuery { + query := (&ItemClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withItems = query + return aq +} + // WithOwner tells the query-builder to eager-load the nodes that are connected to // the "owner" edge. The optional arguments are used to configure the query builder of the edge. func (aq *AssetQuery) WithOwner(opts ...func(*AccountQuery)) *AssetQuery { @@ -408,8 +480,10 @@ func (aq *AssetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Asset, var ( nodes = []*Asset{} _spec = aq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [4]bool{ aq.withPosts != nil, + aq.withClusters != nil, + aq.withItems != nil, aq.withOwner != nil, } ) @@ -441,6 +515,20 @@ func (aq *AssetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Asset, return nil, err } } + if query := aq.withClusters; query != nil { + if err := aq.loadClusters(ctx, query, nodes, + func(n *Asset) { n.Edges.Clusters = []*Cluster{} }, + func(n *Asset, e *Cluster) { n.Edges.Clusters = append(n.Edges.Clusters, e) }); err != nil { + return nil, err + } + } + if query := aq.withItems; query != nil { + if err := aq.loadItems(ctx, query, nodes, + func(n *Asset) { n.Edges.Items = []*Item{} }, + func(n *Asset, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + return nil, err + } + } if query := aq.withOwner; query != nil { if err := aq.loadOwner(ctx, query, nodes, nil, func(n *Asset, e *Account) { n.Edges.Owner = e }); err != nil { @@ -511,6 +599,128 @@ func (aq *AssetQuery) loadPosts(ctx context.Context, query *PostQuery, nodes []* } return nil } +func (aq *AssetQuery) loadClusters(ctx context.Context, query *ClusterQuery, nodes []*Asset, init func(*Asset), assign func(*Asset, *Cluster)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Asset) + nids := make(map[xid.ID]map[*Asset]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(asset.ClustersTable) + s.Join(joinT).On(s.C(cluster.FieldID), joinT.C(asset.ClustersPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(asset.ClustersPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(asset.ClustersPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Asset]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Cluster](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "clusters" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (aq *AssetQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Asset, init func(*Asset), assign func(*Asset, *Item)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Asset) + nids := make(map[xid.ID]map[*Asset]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(asset.ItemsTable) + s.Join(joinT).On(s.C(item.FieldID), joinT.C(asset.ItemsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(asset.ItemsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(asset.ItemsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Asset]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "items" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (aq *AssetQuery) loadOwner(ctx context.Context, query *AccountQuery, nodes []*Asset, init func(*Asset), assign func(*Asset, *Account)) error { ids := make([]xid.ID, 0, len(nodes)) nodeids := make(map[xid.ID][]*Asset) diff --git a/internal/ent/asset_update.go b/internal/ent/asset_update.go index afdd5557b..72b1a8865 100644 --- a/internal/ent/asset_update.go +++ b/internal/ent/asset_update.go @@ -13,6 +13,8 @@ import ( "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/rs/xid" @@ -97,6 +99,36 @@ func (au *AssetUpdate) AddPosts(p ...*Post) *AssetUpdate { return au.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (au *AssetUpdate) AddClusterIDs(ids ...xid.ID) *AssetUpdate { + au.mutation.AddClusterIDs(ids...) + return au +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (au *AssetUpdate) AddClusters(c ...*Cluster) *AssetUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return au.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (au *AssetUpdate) AddItemIDs(ids ...xid.ID) *AssetUpdate { + au.mutation.AddItemIDs(ids...) + return au +} + +// AddItems adds the "items" edges to the Item entity. +func (au *AssetUpdate) AddItems(i ...*Item) *AssetUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return au.AddItemIDs(ids...) +} + // SetOwnerID sets the "owner" edge to the Account entity by ID. func (au *AssetUpdate) SetOwnerID(id xid.ID) *AssetUpdate { au.mutation.SetOwnerID(id) @@ -134,6 +166,48 @@ func (au *AssetUpdate) RemovePosts(p ...*Post) *AssetUpdate { return au.RemovePostIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (au *AssetUpdate) ClearClusters() *AssetUpdate { + au.mutation.ClearClusters() + return au +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (au *AssetUpdate) RemoveClusterIDs(ids ...xid.ID) *AssetUpdate { + au.mutation.RemoveClusterIDs(ids...) + return au +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (au *AssetUpdate) RemoveClusters(c ...*Cluster) *AssetUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return au.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (au *AssetUpdate) ClearItems() *AssetUpdate { + au.mutation.ClearItems() + return au +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (au *AssetUpdate) RemoveItemIDs(ids ...xid.ID) *AssetUpdate { + au.mutation.RemoveItemIDs(ids...) + return au +} + +// RemoveItems removes "items" edges to Item entities. +func (au *AssetUpdate) RemoveItems(i ...*Item) *AssetUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return au.RemoveItemIDs(ids...) +} + // ClearOwner clears the "owner" edge to the Account entity. func (au *AssetUpdate) ClearOwner() *AssetUpdate { au.mutation.ClearOwner() @@ -268,6 +342,96 @@ func (au *AssetUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if au.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedClustersIDs(); len(nodes) > 0 && !au.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if au.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedItemsIDs(); len(nodes) > 0 && !au.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if au.mutation.OwnerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -384,6 +548,36 @@ func (auo *AssetUpdateOne) AddPosts(p ...*Post) *AssetUpdateOne { return auo.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (auo *AssetUpdateOne) AddClusterIDs(ids ...xid.ID) *AssetUpdateOne { + auo.mutation.AddClusterIDs(ids...) + return auo +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (auo *AssetUpdateOne) AddClusters(c ...*Cluster) *AssetUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return auo.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (auo *AssetUpdateOne) AddItemIDs(ids ...xid.ID) *AssetUpdateOne { + auo.mutation.AddItemIDs(ids...) + return auo +} + +// AddItems adds the "items" edges to the Item entity. +func (auo *AssetUpdateOne) AddItems(i ...*Item) *AssetUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return auo.AddItemIDs(ids...) +} + // SetOwnerID sets the "owner" edge to the Account entity by ID. func (auo *AssetUpdateOne) SetOwnerID(id xid.ID) *AssetUpdateOne { auo.mutation.SetOwnerID(id) @@ -421,6 +615,48 @@ func (auo *AssetUpdateOne) RemovePosts(p ...*Post) *AssetUpdateOne { return auo.RemovePostIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (auo *AssetUpdateOne) ClearClusters() *AssetUpdateOne { + auo.mutation.ClearClusters() + return auo +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (auo *AssetUpdateOne) RemoveClusterIDs(ids ...xid.ID) *AssetUpdateOne { + auo.mutation.RemoveClusterIDs(ids...) + return auo +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (auo *AssetUpdateOne) RemoveClusters(c ...*Cluster) *AssetUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return auo.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (auo *AssetUpdateOne) ClearItems() *AssetUpdateOne { + auo.mutation.ClearItems() + return auo +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (auo *AssetUpdateOne) RemoveItemIDs(ids ...xid.ID) *AssetUpdateOne { + auo.mutation.RemoveItemIDs(ids...) + return auo +} + +// RemoveItems removes "items" edges to Item entities. +func (auo *AssetUpdateOne) RemoveItems(i ...*Item) *AssetUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return auo.RemoveItemIDs(ids...) +} + // ClearOwner clears the "owner" edge to the Account entity. func (auo *AssetUpdateOne) ClearOwner() *AssetUpdateOne { auo.mutation.ClearOwner() @@ -585,6 +821,96 @@ func (auo *AssetUpdateOne) sqlSave(ctx context.Context) (_node *Asset, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if auo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedClustersIDs(); len(nodes) > 0 && !auo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ClustersTable, + Columns: asset.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if auo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedItemsIDs(); len(nodes) > 0 && !auo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: asset.ItemsTable, + Columns: asset.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if auo.mutation.OwnerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/ent/client.go b/internal/ent/client.go index f5904ccb2..1257a26f1 100644 --- a/internal/ent/client.go +++ b/internal/ent/client.go @@ -19,7 +19,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" "github.com/Southclaws/storyden/internal/ent/category" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/notification" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/react" @@ -41,8 +43,12 @@ type Client struct { Authentication *AuthenticationClient // Category is the client for interacting with the Category builders. Category *CategoryClient + // Cluster is the client for interacting with the Cluster builders. + Cluster *ClusterClient // Collection is the client for interacting with the Collection builders. Collection *CollectionClient + // Item is the client for interacting with the Item builders. + Item *ItemClient // Notification is the client for interacting with the Notification builders. Notification *NotificationClient // Post is the client for interacting with the Post builders. @@ -72,7 +78,9 @@ func (c *Client) init() { c.Asset = NewAssetClient(c.config) c.Authentication = NewAuthenticationClient(c.config) c.Category = NewCategoryClient(c.config) + c.Cluster = NewClusterClient(c.config) c.Collection = NewCollectionClient(c.config) + c.Item = NewItemClient(c.config) c.Notification = NewNotificationClient(c.config) c.Post = NewPostClient(c.config) c.React = NewReactClient(c.config) @@ -165,7 +173,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Asset: NewAssetClient(cfg), Authentication: NewAuthenticationClient(cfg), Category: NewCategoryClient(cfg), + Cluster: NewClusterClient(cfg), Collection: NewCollectionClient(cfg), + Item: NewItemClient(cfg), Notification: NewNotificationClient(cfg), Post: NewPostClient(cfg), React: NewReactClient(cfg), @@ -195,7 +205,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Asset: NewAssetClient(cfg), Authentication: NewAuthenticationClient(cfg), Category: NewCategoryClient(cfg), + Cluster: NewClusterClient(cfg), Collection: NewCollectionClient(cfg), + Item: NewItemClient(cfg), Notification: NewNotificationClient(cfg), Post: NewPostClient(cfg), React: NewReactClient(cfg), @@ -231,8 +243,8 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Account, c.Asset, c.Authentication, c.Category, c.Collection, c.Notification, - c.Post, c.React, c.Role, c.Setting, c.Tag, + c.Account, c.Asset, c.Authentication, c.Category, c.Cluster, c.Collection, + c.Item, c.Notification, c.Post, c.React, c.Role, c.Setting, c.Tag, } { n.Use(hooks...) } @@ -242,8 +254,8 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Account, c.Asset, c.Authentication, c.Category, c.Collection, c.Notification, - c.Post, c.React, c.Role, c.Setting, c.Tag, + c.Account, c.Asset, c.Authentication, c.Category, c.Cluster, c.Collection, + c.Item, c.Notification, c.Post, c.React, c.Role, c.Setting, c.Tag, } { n.Intercept(interceptors...) } @@ -260,8 +272,12 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Authentication.mutate(ctx, m) case *CategoryMutation: return c.Category.mutate(ctx, m) + case *ClusterMutation: + return c.Cluster.mutate(ctx, m) case *CollectionMutation: return c.Collection.mutate(ctx, m) + case *ItemMutation: + return c.Item.mutate(ctx, m) case *NotificationMutation: return c.Notification.mutate(ctx, m) case *PostMutation: @@ -468,6 +484,38 @@ func (c *AccountClient) QueryCollections(a *Account) *CollectionQuery { return query } +// QueryClusters queries the clusters edge of a Account. +func (c *AccountClient) QueryClusters(a *Account) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(account.Table, account.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, account.ClustersTable, account.ClustersColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Account. +func (c *AccountClient) QueryItems(a *Account) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(account.Table, account.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, account.ItemsTable, account.ItemsColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryAssets queries the assets edge of a Account. func (c *AccountClient) QueryAssets(a *Account) *AssetQuery { query := (&AssetClient{config: c.config}).Query() @@ -618,6 +666,38 @@ func (c *AssetClient) QueryPosts(a *Asset) *PostQuery { return query } +// QueryClusters queries the clusters edge of a Asset. +func (c *AssetClient) QueryClusters(a *Asset) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(asset.Table, asset.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, asset.ClustersTable, asset.ClustersPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Asset. +func (c *AssetClient) QueryItems(a *Asset) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(asset.Table, asset.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, asset.ItemsTable, asset.ItemsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryOwner queries the owner edge of a Asset. func (c *AssetClient) QueryOwner(a *Asset) *AccountQuery { query := (&AccountClient{config: c.config}).Query() @@ -927,6 +1007,220 @@ func (c *CategoryClient) mutate(ctx context.Context, m *CategoryMutation) (Value } } +// ClusterClient is a client for the Cluster schema. +type ClusterClient struct { + config +} + +// NewClusterClient returns a client for the Cluster from the given config. +func NewClusterClient(c config) *ClusterClient { + return &ClusterClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `cluster.Hooks(f(g(h())))`. +func (c *ClusterClient) Use(hooks ...Hook) { + c.hooks.Cluster = append(c.hooks.Cluster, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `cluster.Intercept(f(g(h())))`. +func (c *ClusterClient) Intercept(interceptors ...Interceptor) { + c.inters.Cluster = append(c.inters.Cluster, interceptors...) +} + +// Create returns a builder for creating a Cluster entity. +func (c *ClusterClient) Create() *ClusterCreate { + mutation := newClusterMutation(c.config, OpCreate) + return &ClusterCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Cluster entities. +func (c *ClusterClient) CreateBulk(builders ...*ClusterCreate) *ClusterCreateBulk { + return &ClusterCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Cluster. +func (c *ClusterClient) Update() *ClusterUpdate { + mutation := newClusterMutation(c.config, OpUpdate) + return &ClusterUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ClusterClient) UpdateOne(cl *Cluster) *ClusterUpdateOne { + mutation := newClusterMutation(c.config, OpUpdateOne, withCluster(cl)) + return &ClusterUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ClusterClient) UpdateOneID(id xid.ID) *ClusterUpdateOne { + mutation := newClusterMutation(c.config, OpUpdateOne, withClusterID(id)) + return &ClusterUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Cluster. +func (c *ClusterClient) Delete() *ClusterDelete { + mutation := newClusterMutation(c.config, OpDelete) + return &ClusterDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ClusterClient) DeleteOne(cl *Cluster) *ClusterDeleteOne { + return c.DeleteOneID(cl.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ClusterClient) DeleteOneID(id xid.ID) *ClusterDeleteOne { + builder := c.Delete().Where(cluster.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ClusterDeleteOne{builder} +} + +// Query returns a query builder for Cluster. +func (c *ClusterClient) Query() *ClusterQuery { + return &ClusterQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeCluster}, + inters: c.Interceptors(), + } +} + +// Get returns a Cluster entity by its id. +func (c *ClusterClient) Get(ctx context.Context, id xid.ID) (*Cluster, error) { + return c.Query().Where(cluster.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ClusterClient) GetX(ctx context.Context, id xid.ID) *Cluster { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryOwner queries the owner edge of a Cluster. +func (c *ClusterClient) QueryOwner(cl *Cluster) *AccountQuery { + query := (&AccountClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(account.Table, account.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, cluster.OwnerTable, cluster.OwnerColumn), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryParent queries the parent edge of a Cluster. +func (c *ClusterClient) QueryParent(cl *Cluster) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, cluster.ParentTable, cluster.ParentColumn), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryClusters queries the clusters edge of a Cluster. +func (c *ClusterClient) QueryClusters(cl *Cluster) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, cluster.ClustersTable, cluster.ClustersColumn), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Cluster. +func (c *ClusterClient) QueryItems(cl *Cluster) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, cluster.ItemsTable, cluster.ItemsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAssets queries the assets edge of a Cluster. +func (c *ClusterClient) QueryAssets(cl *Cluster) *AssetQuery { + query := (&AssetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, cluster.AssetsTable, cluster.AssetsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTags queries the tags edge of a Cluster. +func (c *ClusterClient) QueryTags(cl *Cluster) *TagQuery { + query := (&TagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := cl.ID + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, id), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, cluster.TagsTable, cluster.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ClusterClient) Hooks() []Hook { + return c.hooks.Cluster +} + +// Interceptors returns the client interceptors. +func (c *ClusterClient) Interceptors() []Interceptor { + return c.inters.Cluster +} + +func (c *ClusterClient) mutate(ctx context.Context, m *ClusterMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ClusterCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ClusterUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ClusterUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ClusterDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Cluster mutation op: %q", m.Op()) + } +} + // CollectionClient is a client for the Collection schema. type CollectionClient struct { config @@ -1077,6 +1371,188 @@ func (c *CollectionClient) mutate(ctx context.Context, m *CollectionMutation) (V } } +// ItemClient is a client for the Item schema. +type ItemClient struct { + config +} + +// NewItemClient returns a client for the Item from the given config. +func NewItemClient(c config) *ItemClient { + return &ItemClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `item.Hooks(f(g(h())))`. +func (c *ItemClient) Use(hooks ...Hook) { + c.hooks.Item = append(c.hooks.Item, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`. +func (c *ItemClient) Intercept(interceptors ...Interceptor) { + c.inters.Item = append(c.inters.Item, interceptors...) +} + +// Create returns a builder for creating a Item entity. +func (c *ItemClient) Create() *ItemCreate { + mutation := newItemMutation(c.config, OpCreate) + return &ItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Item entities. +func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk { + return &ItemCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Item. +func (c *ItemClient) Update() *ItemUpdate { + mutation := newItemMutation(c.config, OpUpdate) + return &ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ItemClient) UpdateOne(i *Item) *ItemUpdateOne { + mutation := newItemMutation(c.config, OpUpdateOne, withItem(i)) + return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ItemClient) UpdateOneID(id xid.ID) *ItemUpdateOne { + mutation := newItemMutation(c.config, OpUpdateOne, withItemID(id)) + return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Item. +func (c *ItemClient) Delete() *ItemDelete { + mutation := newItemMutation(c.config, OpDelete) + return &ItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ItemClient) DeleteOne(i *Item) *ItemDeleteOne { + return c.DeleteOneID(i.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ItemClient) DeleteOneID(id xid.ID) *ItemDeleteOne { + builder := c.Delete().Where(item.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ItemDeleteOne{builder} +} + +// Query returns a query builder for Item. +func (c *ItemClient) Query() *ItemQuery { + return &ItemQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeItem}, + inters: c.Interceptors(), + } +} + +// Get returns a Item entity by its id. +func (c *ItemClient) Get(ctx context.Context, id xid.ID) (*Item, error) { + return c.Query().Where(item.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ItemClient) GetX(ctx context.Context, id xid.ID) *Item { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryOwner queries the owner edge of a Item. +func (c *ItemClient) QueryOwner(i *Item) *AccountQuery { + query := (&AccountClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := i.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(account.Table, account.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.OwnerTable, item.OwnerColumn), + ) + fromV = sqlgraph.Neighbors(i.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryClusters queries the clusters edge of a Item. +func (c *ItemClient) QueryClusters(i *Item) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := i.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.ClustersTable, item.ClustersPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(i.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAssets queries the assets edge of a Item. +func (c *ItemClient) QueryAssets(i *Item) *AssetQuery { + query := (&AssetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := i.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, item.AssetsTable, item.AssetsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(i.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTags queries the tags edge of a Item. +func (c *ItemClient) QueryTags(i *Item) *TagQuery { + query := (&TagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := i.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.TagsTable, item.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(i.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ItemClient) Hooks() []Hook { + return c.hooks.Item +} + +// Interceptors returns the client interceptors. +func (c *ItemClient) Interceptors() []Interceptor { + return c.inters.Item +} + +func (c *ItemClient) mutate(ctx context.Context, m *ItemMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Item mutation op: %q", m.Op()) + } +} + // NotificationClient is a client for the Notification schema. type NotificationClient struct { config @@ -1984,6 +2460,38 @@ func (c *TagClient) QueryPosts(t *Tag) *PostQuery { return query } +// QueryClusters queries the clusters edge of a Tag. +func (c *TagClient) QueryClusters(t *Tag) *ClusterQuery { + query := (&ClusterClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, id), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, tag.ClustersTable, tag.ClustersPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Tag. +func (c *TagClient) QueryItems(t *Tag) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, tag.ItemsTable, tag.ItemsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryAccounts queries the accounts edge of a Tag. func (c *TagClient) QueryAccounts(t *Tag) *AccountQuery { query := (&AccountClient{config: c.config}).Query() @@ -2028,11 +2536,11 @@ func (c *TagClient) mutate(ctx context.Context, m *TagMutation) (Value, error) { // hooks and interceptors per client, for fast access. type ( hooks struct { - Account, Asset, Authentication, Category, Collection, Notification, Post, React, - Role, Setting, Tag []ent.Hook + Account, Asset, Authentication, Category, Cluster, Collection, Item, + Notification, Post, React, Role, Setting, Tag []ent.Hook } inters struct { - Account, Asset, Authentication, Category, Collection, Notification, Post, React, - Role, Setting, Tag []ent.Interceptor + Account, Asset, Authentication, Category, Cluster, Collection, Item, + Notification, Post, React, Role, Setting, Tag []ent.Interceptor } ) diff --git a/internal/ent/cluster.go b/internal/ent/cluster.go new file mode 100644 index 000000000..0f1a97485 --- /dev/null +++ b/internal/ent/cluster.go @@ -0,0 +1,292 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent/dialect/sql" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/rs/xid" +) + +// Cluster is the model entity for the Cluster schema. +type Cluster struct { + config `json:"-"` + // ID of the ent. + ID xid.ID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Slug holds the value of the "slug" field. + Slug string `json:"slug,omitempty"` + // ImageURL holds the value of the "image_url" field. + ImageURL *string `json:"image_url,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // ParentClusterID holds the value of the "parent_cluster_id" field. + ParentClusterID xid.ID `json:"parent_cluster_id,omitempty"` + // AccountID holds the value of the "account_id" field. + AccountID xid.ID `json:"account_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ClusterQuery when eager-loading is set. + Edges ClusterEdges `json:"edges"` +} + +// ClusterEdges holds the relations/edges for other nodes in the graph. +type ClusterEdges struct { + // Owner holds the value of the owner edge. + Owner *Account `json:"owner,omitempty"` + // A many-to-many recursive self reference. The parent cluster, if any. + Parent *Cluster `json:"parent,omitempty"` + // Clusters holds the value of the clusters edge. + Clusters []*Cluster `json:"clusters,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` + // Assets holds the value of the assets edge. + Assets []*Asset `json:"assets,omitempty"` + // Tags holds the value of the tags edge. + Tags []*Tag `json:"tags,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [6]bool +} + +// OwnerOrErr returns the Owner value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ClusterEdges) OwnerOrErr() (*Account, error) { + if e.loadedTypes[0] { + if e.Owner == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: account.Label} + } + return e.Owner, nil + } + return nil, &NotLoadedError{edge: "owner"} +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ClusterEdges) ParentOrErr() (*Cluster, error) { + if e.loadedTypes[1] { + if e.Parent == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: cluster.Label} + } + return e.Parent, nil + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ClustersOrErr returns the Clusters value or an error if the edge +// was not loaded in eager-loading. +func (e ClusterEdges) ClustersOrErr() ([]*Cluster, error) { + if e.loadedTypes[2] { + return e.Clusters, nil + } + return nil, &NotLoadedError{edge: "clusters"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e ClusterEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[3] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} +} + +// AssetsOrErr returns the Assets value or an error if the edge +// was not loaded in eager-loading. +func (e ClusterEdges) AssetsOrErr() ([]*Asset, error) { + if e.loadedTypes[4] { + return e.Assets, nil + } + return nil, &NotLoadedError{edge: "assets"} +} + +// TagsOrErr returns the Tags value or an error if the edge +// was not loaded in eager-loading. +func (e ClusterEdges) TagsOrErr() ([]*Tag, error) { + if e.loadedTypes[5] { + return e.Tags, nil + } + return nil, &NotLoadedError{edge: "tags"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Cluster) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case cluster.FieldName, cluster.FieldSlug, cluster.FieldImageURL, cluster.FieldDescription: + values[i] = new(sql.NullString) + case cluster.FieldCreatedAt, cluster.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case cluster.FieldID, cluster.FieldParentClusterID, cluster.FieldAccountID: + values[i] = new(xid.ID) + default: + return nil, fmt.Errorf("unexpected column %q for type Cluster", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Cluster fields. +func (c *Cluster) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case cluster.FieldID: + if value, ok := values[i].(*xid.ID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + c.ID = *value + } + case cluster.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + c.CreatedAt = value.Time + } + case cluster.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + c.UpdatedAt = value.Time + } + case cluster.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + c.Name = value.String + } + case cluster.FieldSlug: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field slug", values[i]) + } else if value.Valid { + c.Slug = value.String + } + case cluster.FieldImageURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field image_url", values[i]) + } else if value.Valid { + c.ImageURL = new(string) + *c.ImageURL = value.String + } + case cluster.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + c.Description = value.String + } + case cluster.FieldParentClusterID: + if value, ok := values[i].(*xid.ID); !ok { + return fmt.Errorf("unexpected type %T for field parent_cluster_id", values[i]) + } else if value != nil { + c.ParentClusterID = *value + } + case cluster.FieldAccountID: + if value, ok := values[i].(*xid.ID); !ok { + return fmt.Errorf("unexpected type %T for field account_id", values[i]) + } else if value != nil { + c.AccountID = *value + } + } + } + return nil +} + +// QueryOwner queries the "owner" edge of the Cluster entity. +func (c *Cluster) QueryOwner() *AccountQuery { + return NewClusterClient(c.config).QueryOwner(c) +} + +// QueryParent queries the "parent" edge of the Cluster entity. +func (c *Cluster) QueryParent() *ClusterQuery { + return NewClusterClient(c.config).QueryParent(c) +} + +// QueryClusters queries the "clusters" edge of the Cluster entity. +func (c *Cluster) QueryClusters() *ClusterQuery { + return NewClusterClient(c.config).QueryClusters(c) +} + +// QueryItems queries the "items" edge of the Cluster entity. +func (c *Cluster) QueryItems() *ItemQuery { + return NewClusterClient(c.config).QueryItems(c) +} + +// QueryAssets queries the "assets" edge of the Cluster entity. +func (c *Cluster) QueryAssets() *AssetQuery { + return NewClusterClient(c.config).QueryAssets(c) +} + +// QueryTags queries the "tags" edge of the Cluster entity. +func (c *Cluster) QueryTags() *TagQuery { + return NewClusterClient(c.config).QueryTags(c) +} + +// Update returns a builder for updating this Cluster. +// Note that you need to call Cluster.Unwrap() before calling this method if this Cluster +// was returned from a transaction, and the transaction was committed or rolled back. +func (c *Cluster) Update() *ClusterUpdateOne { + return NewClusterClient(c.config).UpdateOne(c) +} + +// Unwrap unwraps the Cluster entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (c *Cluster) Unwrap() *Cluster { + _tx, ok := c.config.driver.(*txDriver) + if !ok { + panic("ent: Cluster is not a transactional entity") + } + c.config.driver = _tx.drv + return c +} + +// String implements the fmt.Stringer. +func (c *Cluster) String() string { + var builder strings.Builder + builder.WriteString("Cluster(") + builder.WriteString(fmt.Sprintf("id=%v, ", c.ID)) + builder.WriteString("created_at=") + builder.WriteString(c.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(c.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(c.Name) + builder.WriteString(", ") + builder.WriteString("slug=") + builder.WriteString(c.Slug) + builder.WriteString(", ") + if v := c.ImageURL; v != nil { + builder.WriteString("image_url=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(c.Description) + builder.WriteString(", ") + builder.WriteString("parent_cluster_id=") + builder.WriteString(fmt.Sprintf("%v", c.ParentClusterID)) + builder.WriteString(", ") + builder.WriteString("account_id=") + builder.WriteString(fmt.Sprintf("%v", c.AccountID)) + builder.WriteByte(')') + return builder.String() +} + +// Clusters is a parsable slice of Cluster. +type Clusters []*Cluster diff --git a/internal/ent/cluster/cluster.go b/internal/ent/cluster/cluster.go new file mode 100644 index 000000000..230be4ba2 --- /dev/null +++ b/internal/ent/cluster/cluster.go @@ -0,0 +1,124 @@ +// Code generated by ent, DO NOT EDIT. + +package cluster + +import ( + "time" + + "github.com/rs/xid" +) + +const ( + // Label holds the string label denoting the cluster type in the database. + Label = "cluster" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldSlug holds the string denoting the slug field in the database. + FieldSlug = "slug" + // FieldImageURL holds the string denoting the image_url field in the database. + FieldImageURL = "image_url" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldParentClusterID holds the string denoting the parent_cluster_id field in the database. + FieldParentClusterID = "parent_cluster_id" + // FieldAccountID holds the string denoting the account_id field in the database. + FieldAccountID = "account_id" + // EdgeOwner holds the string denoting the owner edge name in mutations. + EdgeOwner = "owner" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeClusters holds the string denoting the clusters edge name in mutations. + EdgeClusters = "clusters" + // EdgeItems holds the string denoting the items edge name in mutations. + EdgeItems = "items" + // EdgeAssets holds the string denoting the assets edge name in mutations. + EdgeAssets = "assets" + // EdgeTags holds the string denoting the tags edge name in mutations. + EdgeTags = "tags" + // Table holds the table name of the cluster in the database. + Table = "clusters" + // OwnerTable is the table that holds the owner relation/edge. + OwnerTable = "clusters" + // OwnerInverseTable is the table name for the Account entity. + // It exists in this package in order to avoid circular dependency with the "account" package. + OwnerInverseTable = "accounts" + // OwnerColumn is the table column denoting the owner relation/edge. + OwnerColumn = "account_id" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "clusters" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_cluster_id" + // ClustersTable is the table that holds the clusters relation/edge. + ClustersTable = "clusters" + // ClustersColumn is the table column denoting the clusters relation/edge. + ClustersColumn = "parent_cluster_id" + // ItemsTable is the table that holds the items relation/edge. The primary key declared below. + ItemsTable = "cluster_items" + // ItemsInverseTable is the table name for the Item entity. + // It exists in this package in order to avoid circular dependency with the "item" package. + ItemsInverseTable = "items" + // AssetsTable is the table that holds the assets relation/edge. The primary key declared below. + AssetsTable = "cluster_assets" + // AssetsInverseTable is the table name for the Asset entity. + // It exists in this package in order to avoid circular dependency with the "asset" package. + AssetsInverseTable = "assets" + // TagsTable is the table that holds the tags relation/edge. The primary key declared below. + TagsTable = "tag_clusters" + // TagsInverseTable is the table name for the Tag entity. + // It exists in this package in order to avoid circular dependency with the "tag" package. + TagsInverseTable = "tags" +) + +// Columns holds all SQL columns for cluster fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldName, + FieldSlug, + FieldImageURL, + FieldDescription, + FieldParentClusterID, + FieldAccountID, +} + +var ( + // ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the + // primary key for the items relation (M2M). + ItemsPrimaryKey = []string{"cluster_id", "item_id"} + // AssetsPrimaryKey and AssetsColumn2 are the table columns denoting the + // primary key for the assets relation (M2M). + AssetsPrimaryKey = []string{"cluster_id", "asset_id"} + // TagsPrimaryKey and TagsColumn2 are the table columns denoting the + // primary key for the tags relation (M2M). + TagsPrimaryKey = []string{"tag_id", "cluster_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() xid.ID + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(string) error +) diff --git a/internal/ent/cluster/where.go b/internal/ent/cluster/where.go new file mode 100644 index 000000000..8fa282403 --- /dev/null +++ b/internal/ent/cluster/where.go @@ -0,0 +1,791 @@ +// Code generated by ent, DO NOT EDIT. + +package cluster + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/rs/xid" +) + +// ID filters vertices based on their ID field. +func ID(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldName, v)) +} + +// Slug applies equality check predicate on the "slug" field. It's identical to SlugEQ. +func Slug(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldSlug, v)) +} + +// ImageURL applies equality check predicate on the "image_url" field. It's identical to ImageURLEQ. +func ImageURL(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldImageURL, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldDescription, v)) +} + +// ParentClusterID applies equality check predicate on the "parent_cluster_id" field. It's identical to ParentClusterIDEQ. +func ParentClusterID(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldParentClusterID, v)) +} + +// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ. +func AccountID(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldAccountID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContainsFold(FieldName, v)) +} + +// SlugEQ applies the EQ predicate on the "slug" field. +func SlugEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldSlug, v)) +} + +// SlugNEQ applies the NEQ predicate on the "slug" field. +func SlugNEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldSlug, v)) +} + +// SlugIn applies the In predicate on the "slug" field. +func SlugIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldSlug, vs...)) +} + +// SlugNotIn applies the NotIn predicate on the "slug" field. +func SlugNotIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldSlug, vs...)) +} + +// SlugGT applies the GT predicate on the "slug" field. +func SlugGT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldSlug, v)) +} + +// SlugGTE applies the GTE predicate on the "slug" field. +func SlugGTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldSlug, v)) +} + +// SlugLT applies the LT predicate on the "slug" field. +func SlugLT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldSlug, v)) +} + +// SlugLTE applies the LTE predicate on the "slug" field. +func SlugLTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldSlug, v)) +} + +// SlugContains applies the Contains predicate on the "slug" field. +func SlugContains(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContains(FieldSlug, v)) +} + +// SlugHasPrefix applies the HasPrefix predicate on the "slug" field. +func SlugHasPrefix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasPrefix(FieldSlug, v)) +} + +// SlugHasSuffix applies the HasSuffix predicate on the "slug" field. +func SlugHasSuffix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasSuffix(FieldSlug, v)) +} + +// SlugEqualFold applies the EqualFold predicate on the "slug" field. +func SlugEqualFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEqualFold(FieldSlug, v)) +} + +// SlugContainsFold applies the ContainsFold predicate on the "slug" field. +func SlugContainsFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContainsFold(FieldSlug, v)) +} + +// ImageURLEQ applies the EQ predicate on the "image_url" field. +func ImageURLEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldImageURL, v)) +} + +// ImageURLNEQ applies the NEQ predicate on the "image_url" field. +func ImageURLNEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldImageURL, v)) +} + +// ImageURLIn applies the In predicate on the "image_url" field. +func ImageURLIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldImageURL, vs...)) +} + +// ImageURLNotIn applies the NotIn predicate on the "image_url" field. +func ImageURLNotIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldImageURL, vs...)) +} + +// ImageURLGT applies the GT predicate on the "image_url" field. +func ImageURLGT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldImageURL, v)) +} + +// ImageURLGTE applies the GTE predicate on the "image_url" field. +func ImageURLGTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldImageURL, v)) +} + +// ImageURLLT applies the LT predicate on the "image_url" field. +func ImageURLLT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldImageURL, v)) +} + +// ImageURLLTE applies the LTE predicate on the "image_url" field. +func ImageURLLTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldImageURL, v)) +} + +// ImageURLContains applies the Contains predicate on the "image_url" field. +func ImageURLContains(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContains(FieldImageURL, v)) +} + +// ImageURLHasPrefix applies the HasPrefix predicate on the "image_url" field. +func ImageURLHasPrefix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasPrefix(FieldImageURL, v)) +} + +// ImageURLHasSuffix applies the HasSuffix predicate on the "image_url" field. +func ImageURLHasSuffix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasSuffix(FieldImageURL, v)) +} + +// ImageURLIsNil applies the IsNil predicate on the "image_url" field. +func ImageURLIsNil() predicate.Cluster { + return predicate.Cluster(sql.FieldIsNull(FieldImageURL)) +} + +// ImageURLNotNil applies the NotNil predicate on the "image_url" field. +func ImageURLNotNil() predicate.Cluster { + return predicate.Cluster(sql.FieldNotNull(FieldImageURL)) +} + +// ImageURLEqualFold applies the EqualFold predicate on the "image_url" field. +func ImageURLEqualFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEqualFold(FieldImageURL, v)) +} + +// ImageURLContainsFold applies the ContainsFold predicate on the "image_url" field. +func ImageURLContainsFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContainsFold(FieldImageURL, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Cluster { + return predicate.Cluster(sql.FieldContainsFold(FieldDescription, v)) +} + +// ParentClusterIDEQ applies the EQ predicate on the "parent_cluster_id" field. +func ParentClusterIDEQ(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldParentClusterID, v)) +} + +// ParentClusterIDNEQ applies the NEQ predicate on the "parent_cluster_id" field. +func ParentClusterIDNEQ(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldParentClusterID, v)) +} + +// ParentClusterIDIn applies the In predicate on the "parent_cluster_id" field. +func ParentClusterIDIn(vs ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldParentClusterID, vs...)) +} + +// ParentClusterIDNotIn applies the NotIn predicate on the "parent_cluster_id" field. +func ParentClusterIDNotIn(vs ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldParentClusterID, vs...)) +} + +// ParentClusterIDGT applies the GT predicate on the "parent_cluster_id" field. +func ParentClusterIDGT(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldParentClusterID, v)) +} + +// ParentClusterIDGTE applies the GTE predicate on the "parent_cluster_id" field. +func ParentClusterIDGTE(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldParentClusterID, v)) +} + +// ParentClusterIDLT applies the LT predicate on the "parent_cluster_id" field. +func ParentClusterIDLT(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldParentClusterID, v)) +} + +// ParentClusterIDLTE applies the LTE predicate on the "parent_cluster_id" field. +func ParentClusterIDLTE(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldParentClusterID, v)) +} + +// ParentClusterIDContains applies the Contains predicate on the "parent_cluster_id" field. +func ParentClusterIDContains(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldContains(FieldParentClusterID, vc)) +} + +// ParentClusterIDHasPrefix applies the HasPrefix predicate on the "parent_cluster_id" field. +func ParentClusterIDHasPrefix(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldHasPrefix(FieldParentClusterID, vc)) +} + +// ParentClusterIDHasSuffix applies the HasSuffix predicate on the "parent_cluster_id" field. +func ParentClusterIDHasSuffix(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldHasSuffix(FieldParentClusterID, vc)) +} + +// ParentClusterIDIsNil applies the IsNil predicate on the "parent_cluster_id" field. +func ParentClusterIDIsNil() predicate.Cluster { + return predicate.Cluster(sql.FieldIsNull(FieldParentClusterID)) +} + +// ParentClusterIDNotNil applies the NotNil predicate on the "parent_cluster_id" field. +func ParentClusterIDNotNil() predicate.Cluster { + return predicate.Cluster(sql.FieldNotNull(FieldParentClusterID)) +} + +// ParentClusterIDEqualFold applies the EqualFold predicate on the "parent_cluster_id" field. +func ParentClusterIDEqualFold(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldEqualFold(FieldParentClusterID, vc)) +} + +// ParentClusterIDContainsFold applies the ContainsFold predicate on the "parent_cluster_id" field. +func ParentClusterIDContainsFold(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldContainsFold(FieldParentClusterID, vc)) +} + +// AccountIDEQ applies the EQ predicate on the "account_id" field. +func AccountIDEQ(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldEQ(FieldAccountID, v)) +} + +// AccountIDNEQ applies the NEQ predicate on the "account_id" field. +func AccountIDNEQ(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNEQ(FieldAccountID, v)) +} + +// AccountIDIn applies the In predicate on the "account_id" field. +func AccountIDIn(vs ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldIn(FieldAccountID, vs...)) +} + +// AccountIDNotIn applies the NotIn predicate on the "account_id" field. +func AccountIDNotIn(vs ...xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldNotIn(FieldAccountID, vs...)) +} + +// AccountIDGT applies the GT predicate on the "account_id" field. +func AccountIDGT(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGT(FieldAccountID, v)) +} + +// AccountIDGTE applies the GTE predicate on the "account_id" field. +func AccountIDGTE(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldGTE(FieldAccountID, v)) +} + +// AccountIDLT applies the LT predicate on the "account_id" field. +func AccountIDLT(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLT(FieldAccountID, v)) +} + +// AccountIDLTE applies the LTE predicate on the "account_id" field. +func AccountIDLTE(v xid.ID) predicate.Cluster { + return predicate.Cluster(sql.FieldLTE(FieldAccountID, v)) +} + +// AccountIDContains applies the Contains predicate on the "account_id" field. +func AccountIDContains(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldContains(FieldAccountID, vc)) +} + +// AccountIDHasPrefix applies the HasPrefix predicate on the "account_id" field. +func AccountIDHasPrefix(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldHasPrefix(FieldAccountID, vc)) +} + +// AccountIDHasSuffix applies the HasSuffix predicate on the "account_id" field. +func AccountIDHasSuffix(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldHasSuffix(FieldAccountID, vc)) +} + +// AccountIDEqualFold applies the EqualFold predicate on the "account_id" field. +func AccountIDEqualFold(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldEqualFold(FieldAccountID, vc)) +} + +// AccountIDContainsFold applies the ContainsFold predicate on the "account_id" field. +func AccountIDContainsFold(v xid.ID) predicate.Cluster { + vc := v.String() + return predicate.Cluster(sql.FieldContainsFold(FieldAccountID, vc)) +} + +// HasOwner applies the HasEdge predicate on the "owner" edge. +func HasOwner() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates). +func HasOwnerWith(preds ...predicate.Account) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Cluster) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasClusters applies the HasEdge predicate on the "clusters" edge. +func HasClusters() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ClustersTable, ClustersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasClustersWith applies the HasEdge predicate on the "clusters" edge with a given conditions (other predicates). +func HasClustersWith(preds ...predicate.Cluster) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ClustersTable, ClustersColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasItems applies the HasEdge predicate on the "items" edge. +func HasItems() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). +func HasItemsWith(preds ...predicate.Item) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAssets applies the HasEdge predicate on the "assets" edge. +func HasAssets() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, AssetsTable, AssetsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAssetsWith applies the HasEdge predicate on the "assets" edge with a given conditions (other predicates). +func HasAssetsWith(preds ...predicate.Asset) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AssetsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, AssetsTable, AssetsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTags applies the HasEdge predicate on the "tags" edge. +func HasTags() predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates). +func HasTagsWith(preds ...predicate.Tag) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Cluster) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Cluster) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Cluster) predicate.Cluster { + return predicate.Cluster(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/internal/ent/cluster_create.go b/internal/ent/cluster_create.go new file mode 100644 index 000000000..e75523210 --- /dev/null +++ b/internal/ent/cluster_create.go @@ -0,0 +1,1105 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ClusterCreate is the builder for creating a Cluster entity. +type ClusterCreate struct { + config + mutation *ClusterMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (cc *ClusterCreate) SetCreatedAt(t time.Time) *ClusterCreate { + cc.mutation.SetCreatedAt(t) + return cc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (cc *ClusterCreate) SetNillableCreatedAt(t *time.Time) *ClusterCreate { + if t != nil { + cc.SetCreatedAt(*t) + } + return cc +} + +// SetUpdatedAt sets the "updated_at" field. +func (cc *ClusterCreate) SetUpdatedAt(t time.Time) *ClusterCreate { + cc.mutation.SetUpdatedAt(t) + return cc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (cc *ClusterCreate) SetNillableUpdatedAt(t *time.Time) *ClusterCreate { + if t != nil { + cc.SetUpdatedAt(*t) + } + return cc +} + +// SetName sets the "name" field. +func (cc *ClusterCreate) SetName(s string) *ClusterCreate { + cc.mutation.SetName(s) + return cc +} + +// SetSlug sets the "slug" field. +func (cc *ClusterCreate) SetSlug(s string) *ClusterCreate { + cc.mutation.SetSlug(s) + return cc +} + +// SetImageURL sets the "image_url" field. +func (cc *ClusterCreate) SetImageURL(s string) *ClusterCreate { + cc.mutation.SetImageURL(s) + return cc +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (cc *ClusterCreate) SetNillableImageURL(s *string) *ClusterCreate { + if s != nil { + cc.SetImageURL(*s) + } + return cc +} + +// SetDescription sets the "description" field. +func (cc *ClusterCreate) SetDescription(s string) *ClusterCreate { + cc.mutation.SetDescription(s) + return cc +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (cc *ClusterCreate) SetParentClusterID(x xid.ID) *ClusterCreate { + cc.mutation.SetParentClusterID(x) + return cc +} + +// SetNillableParentClusterID sets the "parent_cluster_id" field if the given value is not nil. +func (cc *ClusterCreate) SetNillableParentClusterID(x *xid.ID) *ClusterCreate { + if x != nil { + cc.SetParentClusterID(*x) + } + return cc +} + +// SetAccountID sets the "account_id" field. +func (cc *ClusterCreate) SetAccountID(x xid.ID) *ClusterCreate { + cc.mutation.SetAccountID(x) + return cc +} + +// SetID sets the "id" field. +func (cc *ClusterCreate) SetID(x xid.ID) *ClusterCreate { + cc.mutation.SetID(x) + return cc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (cc *ClusterCreate) SetNillableID(x *xid.ID) *ClusterCreate { + if x != nil { + cc.SetID(*x) + } + return cc +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (cc *ClusterCreate) SetOwnerID(id xid.ID) *ClusterCreate { + cc.mutation.SetOwnerID(id) + return cc +} + +// SetOwner sets the "owner" edge to the Account entity. +func (cc *ClusterCreate) SetOwner(a *Account) *ClusterCreate { + return cc.SetOwnerID(a.ID) +} + +// SetParentID sets the "parent" edge to the Cluster entity by ID. +func (cc *ClusterCreate) SetParentID(id xid.ID) *ClusterCreate { + cc.mutation.SetParentID(id) + return cc +} + +// SetNillableParentID sets the "parent" edge to the Cluster entity by ID if the given value is not nil. +func (cc *ClusterCreate) SetNillableParentID(id *xid.ID) *ClusterCreate { + if id != nil { + cc = cc.SetParentID(*id) + } + return cc +} + +// SetParent sets the "parent" edge to the Cluster entity. +func (cc *ClusterCreate) SetParent(c *Cluster) *ClusterCreate { + return cc.SetParentID(c.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (cc *ClusterCreate) AddClusterIDs(ids ...xid.ID) *ClusterCreate { + cc.mutation.AddClusterIDs(ids...) + return cc +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (cc *ClusterCreate) AddClusters(c ...*Cluster) *ClusterCreate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return cc.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (cc *ClusterCreate) AddItemIDs(ids ...xid.ID) *ClusterCreate { + cc.mutation.AddItemIDs(ids...) + return cc +} + +// AddItems adds the "items" edges to the Item entity. +func (cc *ClusterCreate) AddItems(i ...*Item) *ClusterCreate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return cc.AddItemIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (cc *ClusterCreate) AddAssetIDs(ids ...string) *ClusterCreate { + cc.mutation.AddAssetIDs(ids...) + return cc +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (cc *ClusterCreate) AddAssets(a ...*Asset) *ClusterCreate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return cc.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (cc *ClusterCreate) AddTagIDs(ids ...xid.ID) *ClusterCreate { + cc.mutation.AddTagIDs(ids...) + return cc +} + +// AddTags adds the "tags" edges to the Tag entity. +func (cc *ClusterCreate) AddTags(t ...*Tag) *ClusterCreate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return cc.AddTagIDs(ids...) +} + +// Mutation returns the ClusterMutation object of the builder. +func (cc *ClusterCreate) Mutation() *ClusterMutation { + return cc.mutation +} + +// Save creates the Cluster in the database. +func (cc *ClusterCreate) Save(ctx context.Context) (*Cluster, error) { + cc.defaults() + return withHooks[*Cluster, ClusterMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (cc *ClusterCreate) SaveX(ctx context.Context) *Cluster { + v, err := cc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (cc *ClusterCreate) Exec(ctx context.Context) error { + _, err := cc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cc *ClusterCreate) ExecX(ctx context.Context) { + if err := cc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cc *ClusterCreate) defaults() { + if _, ok := cc.mutation.CreatedAt(); !ok { + v := cluster.DefaultCreatedAt() + cc.mutation.SetCreatedAt(v) + } + if _, ok := cc.mutation.UpdatedAt(); !ok { + v := cluster.DefaultUpdatedAt() + cc.mutation.SetUpdatedAt(v) + } + if _, ok := cc.mutation.ID(); !ok { + v := cluster.DefaultID() + cc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cc *ClusterCreate) check() error { + if _, ok := cc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Cluster.created_at"`)} + } + if _, ok := cc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Cluster.updated_at"`)} + } + if _, ok := cc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Cluster.name"`)} + } + if _, ok := cc.mutation.Slug(); !ok { + return &ValidationError{Name: "slug", err: errors.New(`ent: missing required field "Cluster.slug"`)} + } + if _, ok := cc.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Cluster.description"`)} + } + if _, ok := cc.mutation.AccountID(); !ok { + return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "Cluster.account_id"`)} + } + if v, ok := cc.mutation.ID(); ok { + if err := cluster.IDValidator(v.String()); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Cluster.id": %w`, err)} + } + } + if _, ok := cc.mutation.OwnerID(); !ok { + return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Cluster.owner"`)} + } + return nil +} + +func (cc *ClusterCreate) sqlSave(ctx context.Context) (*Cluster, error) { + if err := cc.check(); err != nil { + return nil, err + } + _node, _spec := cc.createSpec() + if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*xid.ID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + cc.mutation.id = &_node.ID + cc.mutation.done = true + return _node, nil +} + +func (cc *ClusterCreate) createSpec() (*Cluster, *sqlgraph.CreateSpec) { + var ( + _node = &Cluster{config: cc.config} + _spec = sqlgraph.NewCreateSpec(cluster.Table, sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString)) + ) + _spec.OnConflict = cc.conflict + if id, ok := cc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := cc.mutation.CreatedAt(); ok { + _spec.SetField(cluster.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := cc.mutation.UpdatedAt(); ok { + _spec.SetField(cluster.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := cc.mutation.Name(); ok { + _spec.SetField(cluster.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := cc.mutation.Slug(); ok { + _spec.SetField(cluster.FieldSlug, field.TypeString, value) + _node.Slug = value + } + if value, ok := cc.mutation.ImageURL(); ok { + _spec.SetField(cluster.FieldImageURL, field.TypeString, value) + _node.ImageURL = &value + } + if value, ok := cc.mutation.Description(); ok { + _spec.SetField(cluster.FieldDescription, field.TypeString, value) + _node.Description = value + } + if nodes := cc.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.OwnerTable, + Columns: []string{cluster.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.AccountID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := cc.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.ParentTable, + Columns: []string{cluster.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ParentClusterID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := cc.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := cc.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := cc.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := cc.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Cluster.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ClusterUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (cc *ClusterCreate) OnConflict(opts ...sql.ConflictOption) *ClusterUpsertOne { + cc.conflict = opts + return &ClusterUpsertOne{ + create: cc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (cc *ClusterCreate) OnConflictColumns(columns ...string) *ClusterUpsertOne { + cc.conflict = append(cc.conflict, sql.ConflictColumns(columns...)) + return &ClusterUpsertOne{ + create: cc, + } +} + +type ( + // ClusterUpsertOne is the builder for "upsert"-ing + // one Cluster node. + ClusterUpsertOne struct { + create *ClusterCreate + } + + // ClusterUpsert is the "OnConflict" setter. + ClusterUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *ClusterUpsert) SetUpdatedAt(v time.Time) *ClusterUpsert { + u.Set(cluster.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateUpdatedAt() *ClusterUpsert { + u.SetExcluded(cluster.FieldUpdatedAt) + return u +} + +// SetName sets the "name" field. +func (u *ClusterUpsert) SetName(v string) *ClusterUpsert { + u.Set(cluster.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateName() *ClusterUpsert { + u.SetExcluded(cluster.FieldName) + return u +} + +// SetSlug sets the "slug" field. +func (u *ClusterUpsert) SetSlug(v string) *ClusterUpsert { + u.Set(cluster.FieldSlug, v) + return u +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateSlug() *ClusterUpsert { + u.SetExcluded(cluster.FieldSlug) + return u +} + +// SetImageURL sets the "image_url" field. +func (u *ClusterUpsert) SetImageURL(v string) *ClusterUpsert { + u.Set(cluster.FieldImageURL, v) + return u +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateImageURL() *ClusterUpsert { + u.SetExcluded(cluster.FieldImageURL) + return u +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ClusterUpsert) ClearImageURL() *ClusterUpsert { + u.SetNull(cluster.FieldImageURL) + return u +} + +// SetDescription sets the "description" field. +func (u *ClusterUpsert) SetDescription(v string) *ClusterUpsert { + u.Set(cluster.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateDescription() *ClusterUpsert { + u.SetExcluded(cluster.FieldDescription) + return u +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (u *ClusterUpsert) SetParentClusterID(v xid.ID) *ClusterUpsert { + u.Set(cluster.FieldParentClusterID, v) + return u +} + +// UpdateParentClusterID sets the "parent_cluster_id" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateParentClusterID() *ClusterUpsert { + u.SetExcluded(cluster.FieldParentClusterID) + return u +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (u *ClusterUpsert) ClearParentClusterID() *ClusterUpsert { + u.SetNull(cluster.FieldParentClusterID) + return u +} + +// SetAccountID sets the "account_id" field. +func (u *ClusterUpsert) SetAccountID(v xid.ID) *ClusterUpsert { + u.Set(cluster.FieldAccountID, v) + return u +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ClusterUpsert) UpdateAccountID() *ClusterUpsert { + u.SetExcluded(cluster.FieldAccountID) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(cluster.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ClusterUpsertOne) UpdateNewValues() *ClusterUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(cluster.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(cluster.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ClusterUpsertOne) Ignore() *ClusterUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ClusterUpsertOne) DoNothing() *ClusterUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ClusterCreate.OnConflict +// documentation for more info. +func (u *ClusterUpsertOne) Update(set func(*ClusterUpsert)) *ClusterUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ClusterUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ClusterUpsertOne) SetUpdatedAt(v time.Time) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateUpdatedAt() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ClusterUpsertOne) SetName(v string) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateName() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateName() + }) +} + +// SetSlug sets the "slug" field. +func (u *ClusterUpsertOne) SetSlug(v string) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetSlug(v) + }) +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateSlug() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateSlug() + }) +} + +// SetImageURL sets the "image_url" field. +func (u *ClusterUpsertOne) SetImageURL(v string) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetImageURL(v) + }) +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateImageURL() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateImageURL() + }) +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ClusterUpsertOne) ClearImageURL() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.ClearImageURL() + }) +} + +// SetDescription sets the "description" field. +func (u *ClusterUpsertOne) SetDescription(v string) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateDescription() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateDescription() + }) +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (u *ClusterUpsertOne) SetParentClusterID(v xid.ID) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetParentClusterID(v) + }) +} + +// UpdateParentClusterID sets the "parent_cluster_id" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateParentClusterID() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateParentClusterID() + }) +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (u *ClusterUpsertOne) ClearParentClusterID() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.ClearParentClusterID() + }) +} + +// SetAccountID sets the "account_id" field. +func (u *ClusterUpsertOne) SetAccountID(v xid.ID) *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.SetAccountID(v) + }) +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ClusterUpsertOne) UpdateAccountID() *ClusterUpsertOne { + return u.Update(func(s *ClusterUpsert) { + s.UpdateAccountID() + }) +} + +// Exec executes the query. +func (u *ClusterUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ClusterCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ClusterUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ClusterUpsertOne) ID(ctx context.Context) (id xid.ID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ClusterUpsertOne.ID is not supported by MySQL driver. Use ClusterUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ClusterUpsertOne) IDX(ctx context.Context) xid.ID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ClusterCreateBulk is the builder for creating many Cluster entities in bulk. +type ClusterCreateBulk struct { + config + builders []*ClusterCreate + conflict []sql.ConflictOption +} + +// Save creates the Cluster entities in the database. +func (ccb *ClusterCreateBulk) Save(ctx context.Context) ([]*Cluster, error) { + specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) + nodes := make([]*Cluster, len(ccb.builders)) + mutators := make([]Mutator, len(ccb.builders)) + for i := range ccb.builders { + func(i int, root context.Context) { + builder := ccb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ClusterMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = ccb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ccb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ccb *ClusterCreateBulk) SaveX(ctx context.Context) []*Cluster { + v, err := ccb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ccb *ClusterCreateBulk) Exec(ctx context.Context) error { + _, err := ccb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ccb *ClusterCreateBulk) ExecX(ctx context.Context) { + if err := ccb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Cluster.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ClusterUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ccb *ClusterCreateBulk) OnConflict(opts ...sql.ConflictOption) *ClusterUpsertBulk { + ccb.conflict = opts + return &ClusterUpsertBulk{ + create: ccb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ccb *ClusterCreateBulk) OnConflictColumns(columns ...string) *ClusterUpsertBulk { + ccb.conflict = append(ccb.conflict, sql.ConflictColumns(columns...)) + return &ClusterUpsertBulk{ + create: ccb, + } +} + +// ClusterUpsertBulk is the builder for "upsert"-ing +// a bulk of Cluster nodes. +type ClusterUpsertBulk struct { + create *ClusterCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(cluster.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ClusterUpsertBulk) UpdateNewValues() *ClusterUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(cluster.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(cluster.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Cluster.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ClusterUpsertBulk) Ignore() *ClusterUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ClusterUpsertBulk) DoNothing() *ClusterUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ClusterCreateBulk.OnConflict +// documentation for more info. +func (u *ClusterUpsertBulk) Update(set func(*ClusterUpsert)) *ClusterUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ClusterUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ClusterUpsertBulk) SetUpdatedAt(v time.Time) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateUpdatedAt() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ClusterUpsertBulk) SetName(v string) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateName() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateName() + }) +} + +// SetSlug sets the "slug" field. +func (u *ClusterUpsertBulk) SetSlug(v string) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetSlug(v) + }) +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateSlug() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateSlug() + }) +} + +// SetImageURL sets the "image_url" field. +func (u *ClusterUpsertBulk) SetImageURL(v string) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetImageURL(v) + }) +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateImageURL() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateImageURL() + }) +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ClusterUpsertBulk) ClearImageURL() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.ClearImageURL() + }) +} + +// SetDescription sets the "description" field. +func (u *ClusterUpsertBulk) SetDescription(v string) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateDescription() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateDescription() + }) +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (u *ClusterUpsertBulk) SetParentClusterID(v xid.ID) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetParentClusterID(v) + }) +} + +// UpdateParentClusterID sets the "parent_cluster_id" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateParentClusterID() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateParentClusterID() + }) +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (u *ClusterUpsertBulk) ClearParentClusterID() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.ClearParentClusterID() + }) +} + +// SetAccountID sets the "account_id" field. +func (u *ClusterUpsertBulk) SetAccountID(v xid.ID) *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.SetAccountID(v) + }) +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ClusterUpsertBulk) UpdateAccountID() *ClusterUpsertBulk { + return u.Update(func(s *ClusterUpsert) { + s.UpdateAccountID() + }) +} + +// Exec executes the query. +func (u *ClusterUpsertBulk) Exec(ctx context.Context) error { + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ClusterCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ClusterCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ClusterUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/cluster_delete.go b/internal/ent/cluster_delete.go new file mode 100644 index 000000000..264eec228 --- /dev/null +++ b/internal/ent/cluster_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/predicate" +) + +// ClusterDelete is the builder for deleting a Cluster entity. +type ClusterDelete struct { + config + hooks []Hook + mutation *ClusterMutation +} + +// Where appends a list predicates to the ClusterDelete builder. +func (cd *ClusterDelete) Where(ps ...predicate.Cluster) *ClusterDelete { + cd.mutation.Where(ps...) + return cd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (cd *ClusterDelete) Exec(ctx context.Context) (int, error) { + return withHooks[int, ClusterMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (cd *ClusterDelete) ExecX(ctx context.Context) int { + n, err := cd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (cd *ClusterDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(cluster.Table, sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString)) + if ps := cd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, cd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + cd.mutation.done = true + return affected, err +} + +// ClusterDeleteOne is the builder for deleting a single Cluster entity. +type ClusterDeleteOne struct { + cd *ClusterDelete +} + +// Where appends a list predicates to the ClusterDelete builder. +func (cdo *ClusterDeleteOne) Where(ps ...predicate.Cluster) *ClusterDeleteOne { + cdo.cd.mutation.Where(ps...) + return cdo +} + +// Exec executes the deletion query. +func (cdo *ClusterDeleteOne) Exec(ctx context.Context) error { + n, err := cdo.cd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{cluster.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (cdo *ClusterDeleteOne) ExecX(ctx context.Context) { + if err := cdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/cluster_query.go b/internal/ent/cluster_query.go new file mode 100644 index 000000000..7d8a8bd2c --- /dev/null +++ b/internal/ent/cluster_query.go @@ -0,0 +1,1082 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ClusterQuery is the builder for querying Cluster entities. +type ClusterQuery struct { + config + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Cluster + withOwner *AccountQuery + withParent *ClusterQuery + withClusters *ClusterQuery + withItems *ItemQuery + withAssets *AssetQuery + withTags *TagQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ClusterQuery builder. +func (cq *ClusterQuery) Where(ps ...predicate.Cluster) *ClusterQuery { + cq.predicates = append(cq.predicates, ps...) + return cq +} + +// Limit the number of records to be returned by this query. +func (cq *ClusterQuery) Limit(limit int) *ClusterQuery { + cq.ctx.Limit = &limit + return cq +} + +// Offset to start from. +func (cq *ClusterQuery) Offset(offset int) *ClusterQuery { + cq.ctx.Offset = &offset + return cq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (cq *ClusterQuery) Unique(unique bool) *ClusterQuery { + cq.ctx.Unique = &unique + return cq +} + +// Order specifies how the records should be ordered. +func (cq *ClusterQuery) Order(o ...OrderFunc) *ClusterQuery { + cq.order = append(cq.order, o...) + return cq +} + +// QueryOwner chains the current query on the "owner" edge. +func (cq *ClusterQuery) QueryOwner() *AccountQuery { + query := (&AccountClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(account.Table, account.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, cluster.OwnerTable, cluster.OwnerColumn), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryParent chains the current query on the "parent" edge. +func (cq *ClusterQuery) QueryParent() *ClusterQuery { + query := (&ClusterClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, cluster.ParentTable, cluster.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryClusters chains the current query on the "clusters" edge. +func (cq *ClusterQuery) QueryClusters() *ClusterQuery { + query := (&ClusterClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, cluster.ClustersTable, cluster.ClustersColumn), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (cq *ClusterQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, cluster.ItemsTable, cluster.ItemsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAssets chains the current query on the "assets" edge. +func (cq *ClusterQuery) QueryAssets() *AssetQuery { + query := (&AssetClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, cluster.AssetsTable, cluster.AssetsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTags chains the current query on the "tags" edge. +func (cq *ClusterQuery) QueryTags() *TagQuery { + query := (&TagClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(cluster.Table, cluster.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, cluster.TagsTable, cluster.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Cluster entity from the query. +// Returns a *NotFoundError when no Cluster was found. +func (cq *ClusterQuery) First(ctx context.Context) (*Cluster, error) { + nodes, err := cq.Limit(1).All(setContextOp(ctx, cq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{cluster.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (cq *ClusterQuery) FirstX(ctx context.Context) *Cluster { + node, err := cq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Cluster ID from the query. +// Returns a *NotFoundError when no Cluster ID was found. +func (cq *ClusterQuery) FirstID(ctx context.Context) (id xid.ID, err error) { + var ids []xid.ID + if ids, err = cq.Limit(1).IDs(setContextOp(ctx, cq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{cluster.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (cq *ClusterQuery) FirstIDX(ctx context.Context) xid.ID { + id, err := cq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Cluster entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Cluster entity is found. +// Returns a *NotFoundError when no Cluster entities are found. +func (cq *ClusterQuery) Only(ctx context.Context) (*Cluster, error) { + nodes, err := cq.Limit(2).All(setContextOp(ctx, cq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{cluster.Label} + default: + return nil, &NotSingularError{cluster.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (cq *ClusterQuery) OnlyX(ctx context.Context) *Cluster { + node, err := cq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Cluster ID in the query. +// Returns a *NotSingularError when more than one Cluster ID is found. +// Returns a *NotFoundError when no entities are found. +func (cq *ClusterQuery) OnlyID(ctx context.Context) (id xid.ID, err error) { + var ids []xid.ID + if ids, err = cq.Limit(2).IDs(setContextOp(ctx, cq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{cluster.Label} + default: + err = &NotSingularError{cluster.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (cq *ClusterQuery) OnlyIDX(ctx context.Context) xid.ID { + id, err := cq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Clusters. +func (cq *ClusterQuery) All(ctx context.Context) ([]*Cluster, error) { + ctx = setContextOp(ctx, cq.ctx, "All") + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Cluster, *ClusterQuery]() + return withInterceptors[[]*Cluster](ctx, cq, qr, cq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (cq *ClusterQuery) AllX(ctx context.Context) []*Cluster { + nodes, err := cq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Cluster IDs. +func (cq *ClusterQuery) IDs(ctx context.Context) (ids []xid.ID, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } + ctx = setContextOp(ctx, cq.ctx, "IDs") + if err = cq.Select(cluster.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (cq *ClusterQuery) IDsX(ctx context.Context) []xid.ID { + ids, err := cq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (cq *ClusterQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, cq.ctx, "Count") + if err := cq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, cq, querierCount[*ClusterQuery](), cq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (cq *ClusterQuery) CountX(ctx context.Context) int { + count, err := cq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (cq *ClusterQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, cq.ctx, "Exist") + switch _, err := cq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (cq *ClusterQuery) ExistX(ctx context.Context) bool { + exist, err := cq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ClusterQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (cq *ClusterQuery) Clone() *ClusterQuery { + if cq == nil { + return nil + } + return &ClusterQuery{ + config: cq.config, + ctx: cq.ctx.Clone(), + order: append([]OrderFunc{}, cq.order...), + inters: append([]Interceptor{}, cq.inters...), + predicates: append([]predicate.Cluster{}, cq.predicates...), + withOwner: cq.withOwner.Clone(), + withParent: cq.withParent.Clone(), + withClusters: cq.withClusters.Clone(), + withItems: cq.withItems.Clone(), + withAssets: cq.withAssets.Clone(), + withTags: cq.withTags.Clone(), + // clone intermediate query. + sql: cq.sql.Clone(), + path: cq.path, + } +} + +// WithOwner tells the query-builder to eager-load the nodes that are connected to +// the "owner" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithOwner(opts ...func(*AccountQuery)) *ClusterQuery { + query := (&AccountClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withOwner = query + return cq +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithParent(opts ...func(*ClusterQuery)) *ClusterQuery { + query := (&ClusterClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withParent = query + return cq +} + +// WithClusters tells the query-builder to eager-load the nodes that are connected to +// the "clusters" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithClusters(opts ...func(*ClusterQuery)) *ClusterQuery { + query := (&ClusterClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withClusters = query + return cq +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithItems(opts ...func(*ItemQuery)) *ClusterQuery { + query := (&ItemClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withItems = query + return cq +} + +// WithAssets tells the query-builder to eager-load the nodes that are connected to +// the "assets" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithAssets(opts ...func(*AssetQuery)) *ClusterQuery { + query := (&AssetClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withAssets = query + return cq +} + +// WithTags tells the query-builder to eager-load the nodes that are connected to +// the "tags" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *ClusterQuery) WithTags(opts ...func(*TagQuery)) *ClusterQuery { + query := (&TagClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withTags = query + return cq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Cluster.Query(). +// GroupBy(cluster.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (cq *ClusterQuery) GroupBy(field string, fields ...string) *ClusterGroupBy { + cq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ClusterGroupBy{build: cq} + grbuild.flds = &cq.ctx.Fields + grbuild.label = cluster.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Cluster.Query(). +// Select(cluster.FieldCreatedAt). +// Scan(ctx, &v) +func (cq *ClusterQuery) Select(fields ...string) *ClusterSelect { + cq.ctx.Fields = append(cq.ctx.Fields, fields...) + sbuild := &ClusterSelect{ClusterQuery: cq} + sbuild.label = cluster.Label + sbuild.flds, sbuild.scan = &cq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ClusterSelect configured with the given aggregations. +func (cq *ClusterQuery) Aggregate(fns ...AggregateFunc) *ClusterSelect { + return cq.Select().Aggregate(fns...) +} + +func (cq *ClusterQuery) prepareQuery(ctx context.Context) error { + for _, inter := range cq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, cq); err != nil { + return err + } + } + } + for _, f := range cq.ctx.Fields { + if !cluster.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if cq.path != nil { + prev, err := cq.path(ctx) + if err != nil { + return err + } + cq.sql = prev + } + return nil +} + +func (cq *ClusterQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Cluster, error) { + var ( + nodes = []*Cluster{} + _spec = cq.querySpec() + loadedTypes = [6]bool{ + cq.withOwner != nil, + cq.withParent != nil, + cq.withClusters != nil, + cq.withItems != nil, + cq.withAssets != nil, + cq.withTags != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Cluster).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Cluster{config: cq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(cq.modifiers) > 0 { + _spec.Modifiers = cq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, cq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := cq.withOwner; query != nil { + if err := cq.loadOwner(ctx, query, nodes, nil, + func(n *Cluster, e *Account) { n.Edges.Owner = e }); err != nil { + return nil, err + } + } + if query := cq.withParent; query != nil { + if err := cq.loadParent(ctx, query, nodes, nil, + func(n *Cluster, e *Cluster) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := cq.withClusters; query != nil { + if err := cq.loadClusters(ctx, query, nodes, + func(n *Cluster) { n.Edges.Clusters = []*Cluster{} }, + func(n *Cluster, e *Cluster) { n.Edges.Clusters = append(n.Edges.Clusters, e) }); err != nil { + return nil, err + } + } + if query := cq.withItems; query != nil { + if err := cq.loadItems(ctx, query, nodes, + func(n *Cluster) { n.Edges.Items = []*Item{} }, + func(n *Cluster, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + return nil, err + } + } + if query := cq.withAssets; query != nil { + if err := cq.loadAssets(ctx, query, nodes, + func(n *Cluster) { n.Edges.Assets = []*Asset{} }, + func(n *Cluster, e *Asset) { n.Edges.Assets = append(n.Edges.Assets, e) }); err != nil { + return nil, err + } + } + if query := cq.withTags; query != nil { + if err := cq.loadTags(ctx, query, nodes, + func(n *Cluster) { n.Edges.Tags = []*Tag{} }, + func(n *Cluster, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (cq *ClusterQuery) loadOwner(ctx context.Context, query *AccountQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Account)) error { + ids := make([]xid.ID, 0, len(nodes)) + nodeids := make(map[xid.ID][]*Cluster) + for i := range nodes { + fk := nodes[i].AccountID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(account.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "account_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (cq *ClusterQuery) loadParent(ctx context.Context, query *ClusterQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Cluster)) error { + ids := make([]xid.ID, 0, len(nodes)) + nodeids := make(map[xid.ID][]*Cluster) + for i := range nodes { + fk := nodes[i].ParentClusterID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(cluster.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_cluster_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (cq *ClusterQuery) loadClusters(ctx context.Context, query *ClusterQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Cluster)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[xid.ID]*Cluster) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.Where(predicate.Cluster(func(s *sql.Selector) { + s.Where(sql.InValues(cluster.ClustersColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ParentClusterID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_cluster_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (cq *ClusterQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Item)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Cluster) + nids := make(map[xid.ID]map[*Cluster]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(cluster.ItemsTable) + s.Join(joinT).On(s.C(item.FieldID), joinT.C(cluster.ItemsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(cluster.ItemsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(cluster.ItemsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Cluster]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "items" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (cq *ClusterQuery) loadAssets(ctx context.Context, query *AssetQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Asset)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Cluster) + nids := make(map[string]map[*Cluster]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(cluster.AssetsTable) + s.Join(joinT).On(s.C(asset.FieldID), joinT.C(cluster.AssetsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(cluster.AssetsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(cluster.AssetsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Cluster]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Asset](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "assets" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (cq *ClusterQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Cluster, init func(*Cluster), assign func(*Cluster, *Tag)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Cluster) + nids := make(map[xid.ID]map[*Cluster]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(cluster.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(cluster.TagsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(cluster.TagsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(cluster.TagsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Cluster]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (cq *ClusterQuery) sqlCount(ctx context.Context) (int, error) { + _spec := cq.querySpec() + if len(cq.modifiers) > 0 { + _spec.Modifiers = cq.modifiers + } + _spec.Node.Columns = cq.ctx.Fields + if len(cq.ctx.Fields) > 0 { + _spec.Unique = cq.ctx.Unique != nil && *cq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, cq.driver, _spec) +} + +func (cq *ClusterQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(cluster.Table, cluster.Columns, sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString)) + _spec.From = cq.sql + if unique := cq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true + } + if fields := cq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, cluster.FieldID) + for i := range fields { + if fields[i] != cluster.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := cq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := cq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := cq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := cq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (cq *ClusterQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(cq.driver.Dialect()) + t1 := builder.Table(cluster.Table) + columns := cq.ctx.Fields + if len(columns) == 0 { + columns = cluster.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if cq.sql != nil { + selector = cq.sql + selector.Select(selector.Columns(columns...)...) + } + if cq.ctx.Unique != nil && *cq.ctx.Unique { + selector.Distinct() + } + for _, m := range cq.modifiers { + m(selector) + } + for _, p := range cq.predicates { + p(selector) + } + for _, p := range cq.order { + p(selector) + } + if offset := cq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := cq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (cq *ClusterQuery) Modify(modifiers ...func(s *sql.Selector)) *ClusterSelect { + cq.modifiers = append(cq.modifiers, modifiers...) + return cq.Select() +} + +// ClusterGroupBy is the group-by builder for Cluster entities. +type ClusterGroupBy struct { + selector + build *ClusterQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (cgb *ClusterGroupBy) Aggregate(fns ...AggregateFunc) *ClusterGroupBy { + cgb.fns = append(cgb.fns, fns...) + return cgb +} + +// Scan applies the selector query and scans the result into the given value. +func (cgb *ClusterGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, cgb.build.ctx, "GroupBy") + if err := cgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ClusterQuery, *ClusterGroupBy](ctx, cgb.build, cgb, cgb.build.inters, v) +} + +func (cgb *ClusterGroupBy) sqlScan(ctx context.Context, root *ClusterQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(cgb.fns)) + for _, fn := range cgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*cgb.flds)+len(cgb.fns)) + for _, f := range *cgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*cgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := cgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ClusterSelect is the builder for selecting fields of Cluster entities. +type ClusterSelect struct { + *ClusterQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (cs *ClusterSelect) Aggregate(fns ...AggregateFunc) *ClusterSelect { + cs.fns = append(cs.fns, fns...) + return cs +} + +// Scan applies the selector query and scans the result into the given value. +func (cs *ClusterSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, cs.ctx, "Select") + if err := cs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ClusterQuery, *ClusterSelect](ctx, cs.ClusterQuery, cs, cs.inters, v) +} + +func (cs *ClusterSelect) sqlScan(ctx context.Context, root *ClusterQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(cs.fns)) + for _, fn := range cs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*cs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := cs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (cs *ClusterSelect) Modify(modifiers ...func(s *sql.Selector)) *ClusterSelect { + cs.modifiers = append(cs.modifiers, modifiers...) + return cs +} diff --git a/internal/ent/cluster_update.go b/internal/ent/cluster_update.go new file mode 100644 index 000000000..e6bccc994 --- /dev/null +++ b/internal/ent/cluster_update.go @@ -0,0 +1,1261 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ClusterUpdate is the builder for updating Cluster entities. +type ClusterUpdate struct { + config + hooks []Hook + mutation *ClusterMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ClusterUpdate builder. +func (cu *ClusterUpdate) Where(ps ...predicate.Cluster) *ClusterUpdate { + cu.mutation.Where(ps...) + return cu +} + +// SetUpdatedAt sets the "updated_at" field. +func (cu *ClusterUpdate) SetUpdatedAt(t time.Time) *ClusterUpdate { + cu.mutation.SetUpdatedAt(t) + return cu +} + +// SetName sets the "name" field. +func (cu *ClusterUpdate) SetName(s string) *ClusterUpdate { + cu.mutation.SetName(s) + return cu +} + +// SetSlug sets the "slug" field. +func (cu *ClusterUpdate) SetSlug(s string) *ClusterUpdate { + cu.mutation.SetSlug(s) + return cu +} + +// SetImageURL sets the "image_url" field. +func (cu *ClusterUpdate) SetImageURL(s string) *ClusterUpdate { + cu.mutation.SetImageURL(s) + return cu +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (cu *ClusterUpdate) SetNillableImageURL(s *string) *ClusterUpdate { + if s != nil { + cu.SetImageURL(*s) + } + return cu +} + +// ClearImageURL clears the value of the "image_url" field. +func (cu *ClusterUpdate) ClearImageURL() *ClusterUpdate { + cu.mutation.ClearImageURL() + return cu +} + +// SetDescription sets the "description" field. +func (cu *ClusterUpdate) SetDescription(s string) *ClusterUpdate { + cu.mutation.SetDescription(s) + return cu +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (cu *ClusterUpdate) SetParentClusterID(x xid.ID) *ClusterUpdate { + cu.mutation.SetParentClusterID(x) + return cu +} + +// SetNillableParentClusterID sets the "parent_cluster_id" field if the given value is not nil. +func (cu *ClusterUpdate) SetNillableParentClusterID(x *xid.ID) *ClusterUpdate { + if x != nil { + cu.SetParentClusterID(*x) + } + return cu +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (cu *ClusterUpdate) ClearParentClusterID() *ClusterUpdate { + cu.mutation.ClearParentClusterID() + return cu +} + +// SetAccountID sets the "account_id" field. +func (cu *ClusterUpdate) SetAccountID(x xid.ID) *ClusterUpdate { + cu.mutation.SetAccountID(x) + return cu +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (cu *ClusterUpdate) SetOwnerID(id xid.ID) *ClusterUpdate { + cu.mutation.SetOwnerID(id) + return cu +} + +// SetOwner sets the "owner" edge to the Account entity. +func (cu *ClusterUpdate) SetOwner(a *Account) *ClusterUpdate { + return cu.SetOwnerID(a.ID) +} + +// SetParentID sets the "parent" edge to the Cluster entity by ID. +func (cu *ClusterUpdate) SetParentID(id xid.ID) *ClusterUpdate { + cu.mutation.SetParentID(id) + return cu +} + +// SetNillableParentID sets the "parent" edge to the Cluster entity by ID if the given value is not nil. +func (cu *ClusterUpdate) SetNillableParentID(id *xid.ID) *ClusterUpdate { + if id != nil { + cu = cu.SetParentID(*id) + } + return cu +} + +// SetParent sets the "parent" edge to the Cluster entity. +func (cu *ClusterUpdate) SetParent(c *Cluster) *ClusterUpdate { + return cu.SetParentID(c.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (cu *ClusterUpdate) AddClusterIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.AddClusterIDs(ids...) + return cu +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (cu *ClusterUpdate) AddClusters(c ...*Cluster) *ClusterUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return cu.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (cu *ClusterUpdate) AddItemIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.AddItemIDs(ids...) + return cu +} + +// AddItems adds the "items" edges to the Item entity. +func (cu *ClusterUpdate) AddItems(i ...*Item) *ClusterUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return cu.AddItemIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (cu *ClusterUpdate) AddAssetIDs(ids ...string) *ClusterUpdate { + cu.mutation.AddAssetIDs(ids...) + return cu +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (cu *ClusterUpdate) AddAssets(a ...*Asset) *ClusterUpdate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return cu.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (cu *ClusterUpdate) AddTagIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.AddTagIDs(ids...) + return cu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (cu *ClusterUpdate) AddTags(t ...*Tag) *ClusterUpdate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return cu.AddTagIDs(ids...) +} + +// Mutation returns the ClusterMutation object of the builder. +func (cu *ClusterUpdate) Mutation() *ClusterMutation { + return cu.mutation +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (cu *ClusterUpdate) ClearOwner() *ClusterUpdate { + cu.mutation.ClearOwner() + return cu +} + +// ClearParent clears the "parent" edge to the Cluster entity. +func (cu *ClusterUpdate) ClearParent() *ClusterUpdate { + cu.mutation.ClearParent() + return cu +} + +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (cu *ClusterUpdate) ClearClusters() *ClusterUpdate { + cu.mutation.ClearClusters() + return cu +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (cu *ClusterUpdate) RemoveClusterIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.RemoveClusterIDs(ids...) + return cu +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (cu *ClusterUpdate) RemoveClusters(c ...*Cluster) *ClusterUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return cu.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (cu *ClusterUpdate) ClearItems() *ClusterUpdate { + cu.mutation.ClearItems() + return cu +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (cu *ClusterUpdate) RemoveItemIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.RemoveItemIDs(ids...) + return cu +} + +// RemoveItems removes "items" edges to Item entities. +func (cu *ClusterUpdate) RemoveItems(i ...*Item) *ClusterUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return cu.RemoveItemIDs(ids...) +} + +// ClearAssets clears all "assets" edges to the Asset entity. +func (cu *ClusterUpdate) ClearAssets() *ClusterUpdate { + cu.mutation.ClearAssets() + return cu +} + +// RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. +func (cu *ClusterUpdate) RemoveAssetIDs(ids ...string) *ClusterUpdate { + cu.mutation.RemoveAssetIDs(ids...) + return cu +} + +// RemoveAssets removes "assets" edges to Asset entities. +func (cu *ClusterUpdate) RemoveAssets(a ...*Asset) *ClusterUpdate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return cu.RemoveAssetIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (cu *ClusterUpdate) ClearTags() *ClusterUpdate { + cu.mutation.ClearTags() + return cu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (cu *ClusterUpdate) RemoveTagIDs(ids ...xid.ID) *ClusterUpdate { + cu.mutation.RemoveTagIDs(ids...) + return cu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (cu *ClusterUpdate) RemoveTags(t ...*Tag) *ClusterUpdate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return cu.RemoveTagIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (cu *ClusterUpdate) Save(ctx context.Context) (int, error) { + cu.defaults() + return withHooks[int, ClusterMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (cu *ClusterUpdate) SaveX(ctx context.Context) int { + affected, err := cu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (cu *ClusterUpdate) Exec(ctx context.Context) error { + _, err := cu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cu *ClusterUpdate) ExecX(ctx context.Context) { + if err := cu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cu *ClusterUpdate) defaults() { + if _, ok := cu.mutation.UpdatedAt(); !ok { + v := cluster.UpdateDefaultUpdatedAt() + cu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cu *ClusterUpdate) check() error { + if _, ok := cu.mutation.OwnerID(); cu.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Cluster.owner"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cu *ClusterUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ClusterUpdate { + cu.modifiers = append(cu.modifiers, modifiers...) + return cu +} + +func (cu *ClusterUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := cu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(cluster.Table, cluster.Columns, sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString)) + if ps := cu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := cu.mutation.UpdatedAt(); ok { + _spec.SetField(cluster.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := cu.mutation.Name(); ok { + _spec.SetField(cluster.FieldName, field.TypeString, value) + } + if value, ok := cu.mutation.Slug(); ok { + _spec.SetField(cluster.FieldSlug, field.TypeString, value) + } + if value, ok := cu.mutation.ImageURL(); ok { + _spec.SetField(cluster.FieldImageURL, field.TypeString, value) + } + if cu.mutation.ImageURLCleared() { + _spec.ClearField(cluster.FieldImageURL, field.TypeString) + } + if value, ok := cu.mutation.Description(); ok { + _spec.SetField(cluster.FieldDescription, field.TypeString, value) + } + if cu.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.OwnerTable, + Columns: []string{cluster.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.OwnerTable, + Columns: []string{cluster.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cu.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.ParentTable, + Columns: []string{cluster.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.ParentTable, + Columns: []string{cluster.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.RemovedClustersIDs(); len(nodes) > 0 && !cu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cu.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.RemovedItemsIDs(); len(nodes) > 0 && !cu.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cu.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !cu.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.RemovedTagsIDs(); len(nodes) > 0 && !cu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(cu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{cluster.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + cu.mutation.done = true + return n, nil +} + +// ClusterUpdateOne is the builder for updating a single Cluster entity. +type ClusterUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ClusterMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (cuo *ClusterUpdateOne) SetUpdatedAt(t time.Time) *ClusterUpdateOne { + cuo.mutation.SetUpdatedAt(t) + return cuo +} + +// SetName sets the "name" field. +func (cuo *ClusterUpdateOne) SetName(s string) *ClusterUpdateOne { + cuo.mutation.SetName(s) + return cuo +} + +// SetSlug sets the "slug" field. +func (cuo *ClusterUpdateOne) SetSlug(s string) *ClusterUpdateOne { + cuo.mutation.SetSlug(s) + return cuo +} + +// SetImageURL sets the "image_url" field. +func (cuo *ClusterUpdateOne) SetImageURL(s string) *ClusterUpdateOne { + cuo.mutation.SetImageURL(s) + return cuo +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (cuo *ClusterUpdateOne) SetNillableImageURL(s *string) *ClusterUpdateOne { + if s != nil { + cuo.SetImageURL(*s) + } + return cuo +} + +// ClearImageURL clears the value of the "image_url" field. +func (cuo *ClusterUpdateOne) ClearImageURL() *ClusterUpdateOne { + cuo.mutation.ClearImageURL() + return cuo +} + +// SetDescription sets the "description" field. +func (cuo *ClusterUpdateOne) SetDescription(s string) *ClusterUpdateOne { + cuo.mutation.SetDescription(s) + return cuo +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (cuo *ClusterUpdateOne) SetParentClusterID(x xid.ID) *ClusterUpdateOne { + cuo.mutation.SetParentClusterID(x) + return cuo +} + +// SetNillableParentClusterID sets the "parent_cluster_id" field if the given value is not nil. +func (cuo *ClusterUpdateOne) SetNillableParentClusterID(x *xid.ID) *ClusterUpdateOne { + if x != nil { + cuo.SetParentClusterID(*x) + } + return cuo +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (cuo *ClusterUpdateOne) ClearParentClusterID() *ClusterUpdateOne { + cuo.mutation.ClearParentClusterID() + return cuo +} + +// SetAccountID sets the "account_id" field. +func (cuo *ClusterUpdateOne) SetAccountID(x xid.ID) *ClusterUpdateOne { + cuo.mutation.SetAccountID(x) + return cuo +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (cuo *ClusterUpdateOne) SetOwnerID(id xid.ID) *ClusterUpdateOne { + cuo.mutation.SetOwnerID(id) + return cuo +} + +// SetOwner sets the "owner" edge to the Account entity. +func (cuo *ClusterUpdateOne) SetOwner(a *Account) *ClusterUpdateOne { + return cuo.SetOwnerID(a.ID) +} + +// SetParentID sets the "parent" edge to the Cluster entity by ID. +func (cuo *ClusterUpdateOne) SetParentID(id xid.ID) *ClusterUpdateOne { + cuo.mutation.SetParentID(id) + return cuo +} + +// SetNillableParentID sets the "parent" edge to the Cluster entity by ID if the given value is not nil. +func (cuo *ClusterUpdateOne) SetNillableParentID(id *xid.ID) *ClusterUpdateOne { + if id != nil { + cuo = cuo.SetParentID(*id) + } + return cuo +} + +// SetParent sets the "parent" edge to the Cluster entity. +func (cuo *ClusterUpdateOne) SetParent(c *Cluster) *ClusterUpdateOne { + return cuo.SetParentID(c.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (cuo *ClusterUpdateOne) AddClusterIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.AddClusterIDs(ids...) + return cuo +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (cuo *ClusterUpdateOne) AddClusters(c ...*Cluster) *ClusterUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return cuo.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (cuo *ClusterUpdateOne) AddItemIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.AddItemIDs(ids...) + return cuo +} + +// AddItems adds the "items" edges to the Item entity. +func (cuo *ClusterUpdateOne) AddItems(i ...*Item) *ClusterUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return cuo.AddItemIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (cuo *ClusterUpdateOne) AddAssetIDs(ids ...string) *ClusterUpdateOne { + cuo.mutation.AddAssetIDs(ids...) + return cuo +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (cuo *ClusterUpdateOne) AddAssets(a ...*Asset) *ClusterUpdateOne { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return cuo.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (cuo *ClusterUpdateOne) AddTagIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.AddTagIDs(ids...) + return cuo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (cuo *ClusterUpdateOne) AddTags(t ...*Tag) *ClusterUpdateOne { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return cuo.AddTagIDs(ids...) +} + +// Mutation returns the ClusterMutation object of the builder. +func (cuo *ClusterUpdateOne) Mutation() *ClusterMutation { + return cuo.mutation +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (cuo *ClusterUpdateOne) ClearOwner() *ClusterUpdateOne { + cuo.mutation.ClearOwner() + return cuo +} + +// ClearParent clears the "parent" edge to the Cluster entity. +func (cuo *ClusterUpdateOne) ClearParent() *ClusterUpdateOne { + cuo.mutation.ClearParent() + return cuo +} + +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (cuo *ClusterUpdateOne) ClearClusters() *ClusterUpdateOne { + cuo.mutation.ClearClusters() + return cuo +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (cuo *ClusterUpdateOne) RemoveClusterIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.RemoveClusterIDs(ids...) + return cuo +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (cuo *ClusterUpdateOne) RemoveClusters(c ...*Cluster) *ClusterUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return cuo.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (cuo *ClusterUpdateOne) ClearItems() *ClusterUpdateOne { + cuo.mutation.ClearItems() + return cuo +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (cuo *ClusterUpdateOne) RemoveItemIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.RemoveItemIDs(ids...) + return cuo +} + +// RemoveItems removes "items" edges to Item entities. +func (cuo *ClusterUpdateOne) RemoveItems(i ...*Item) *ClusterUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return cuo.RemoveItemIDs(ids...) +} + +// ClearAssets clears all "assets" edges to the Asset entity. +func (cuo *ClusterUpdateOne) ClearAssets() *ClusterUpdateOne { + cuo.mutation.ClearAssets() + return cuo +} + +// RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. +func (cuo *ClusterUpdateOne) RemoveAssetIDs(ids ...string) *ClusterUpdateOne { + cuo.mutation.RemoveAssetIDs(ids...) + return cuo +} + +// RemoveAssets removes "assets" edges to Asset entities. +func (cuo *ClusterUpdateOne) RemoveAssets(a ...*Asset) *ClusterUpdateOne { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return cuo.RemoveAssetIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (cuo *ClusterUpdateOne) ClearTags() *ClusterUpdateOne { + cuo.mutation.ClearTags() + return cuo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (cuo *ClusterUpdateOne) RemoveTagIDs(ids ...xid.ID) *ClusterUpdateOne { + cuo.mutation.RemoveTagIDs(ids...) + return cuo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (cuo *ClusterUpdateOne) RemoveTags(t ...*Tag) *ClusterUpdateOne { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return cuo.RemoveTagIDs(ids...) +} + +// Where appends a list predicates to the ClusterUpdate builder. +func (cuo *ClusterUpdateOne) Where(ps ...predicate.Cluster) *ClusterUpdateOne { + cuo.mutation.Where(ps...) + return cuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (cuo *ClusterUpdateOne) Select(field string, fields ...string) *ClusterUpdateOne { + cuo.fields = append([]string{field}, fields...) + return cuo +} + +// Save executes the query and returns the updated Cluster entity. +func (cuo *ClusterUpdateOne) Save(ctx context.Context) (*Cluster, error) { + cuo.defaults() + return withHooks[*Cluster, ClusterMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (cuo *ClusterUpdateOne) SaveX(ctx context.Context) *Cluster { + node, err := cuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (cuo *ClusterUpdateOne) Exec(ctx context.Context) error { + _, err := cuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (cuo *ClusterUpdateOne) ExecX(ctx context.Context) { + if err := cuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (cuo *ClusterUpdateOne) defaults() { + if _, ok := cuo.mutation.UpdatedAt(); !ok { + v := cluster.UpdateDefaultUpdatedAt() + cuo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (cuo *ClusterUpdateOne) check() error { + if _, ok := cuo.mutation.OwnerID(); cuo.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Cluster.owner"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cuo *ClusterUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ClusterUpdateOne { + cuo.modifiers = append(cuo.modifiers, modifiers...) + return cuo +} + +func (cuo *ClusterUpdateOne) sqlSave(ctx context.Context) (_node *Cluster, err error) { + if err := cuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(cluster.Table, cluster.Columns, sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString)) + id, ok := cuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Cluster.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := cuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, cluster.FieldID) + for _, f := range fields { + if !cluster.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != cluster.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := cuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := cuo.mutation.UpdatedAt(); ok { + _spec.SetField(cluster.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := cuo.mutation.Name(); ok { + _spec.SetField(cluster.FieldName, field.TypeString, value) + } + if value, ok := cuo.mutation.Slug(); ok { + _spec.SetField(cluster.FieldSlug, field.TypeString, value) + } + if value, ok := cuo.mutation.ImageURL(); ok { + _spec.SetField(cluster.FieldImageURL, field.TypeString, value) + } + if cuo.mutation.ImageURLCleared() { + _spec.ClearField(cluster.FieldImageURL, field.TypeString) + } + if value, ok := cuo.mutation.Description(); ok { + _spec.SetField(cluster.FieldDescription, field.TypeString, value) + } + if cuo.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.OwnerTable, + Columns: []string{cluster.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.OwnerTable, + Columns: []string{cluster.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cuo.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.ParentTable, + Columns: []string{cluster.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: cluster.ParentTable, + Columns: []string{cluster.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.RemovedClustersIDs(); len(nodes) > 0 && !cuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: cluster.ClustersTable, + Columns: []string{cluster.ClustersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cuo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.RemovedItemsIDs(); len(nodes) > 0 && !cuo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.ItemsTable, + Columns: cluster.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cuo.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !cuo.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: cluster.AssetsTable, + Columns: cluster.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if cuo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !cuo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: cluster.TagsTable, + Columns: cluster.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(cuo.modifiers...) + _node = &Cluster{config: cuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{cluster.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + cuo.mutation.done = true + return _node, nil +} diff --git a/internal/ent/ent.go b/internal/ent/ent.go index 947f79c98..23b6b056f 100644 --- a/internal/ent/ent.go +++ b/internal/ent/ent.go @@ -15,7 +15,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" "github.com/Southclaws/storyden/internal/ent/category" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/notification" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/react" @@ -79,7 +81,9 @@ func columnChecker(table string) func(string) error { asset.Table: asset.ValidColumn, authentication.Table: authentication.ValidColumn, category.Table: category.ValidColumn, + cluster.Table: cluster.ValidColumn, collection.Table: collection.ValidColumn, + item.Table: item.ValidColumn, notification.Table: notification.ValidColumn, post.Table: post.ValidColumn, react.Table: react.ValidColumn, diff --git a/internal/ent/er.html b/internal/ent/er.html new file mode 100644 index 000000000..25b1c3af8 --- /dev/null +++ b/internal/ent/er.html @@ -0,0 +1,168 @@ + + + + + + +
+erDiagram + Account { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + timeDOTTime deleted_at + string handle + string name + string bio + bool admin + } + Asset { + string id + timeDOTTime created_at + timeDOTTime updated_at + string url + string mimetype + int width + int height + xidDOTID account_id + } + Authentication { + xidDOTID id + timeDOTTime created_at + string service + string identifier + string token + mapLBRACKstringRBRACKinterface {} metadata + } + Category { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + string name + string slug + string description + string colour + int sort + bool admin + mapLBRACKstringRBRACKinterface {} metadata + } + Cluster { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + string name + string slug + string image_url + string description + xidDOTID parent_cluster_id + xidDOTID account_id + } + Collection { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + string name + string description + } + Item { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + string name + string slug + string image_url + string description + xidDOTID account_id + } + Notification { + xidDOTID id + timeDOTTime created_at + string title + string description + string link + bool read + } + Post { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + timeDOTTime deleted_at + bool first + string title + string slug + bool pinned + xidDOTID root_post_id + xidDOTID reply_to_post_id + string body + string short + mapLBRACKstringRBRACKinterface {} metadata + postDOTStatus status + string url + xidDOTID category_id + } + React { + xidDOTID id + timeDOTTime created_at + xidDOTID account_id + xidDOTID post_id + string emoji + } + Role { + xidDOTID id + timeDOTTime created_at + timeDOTTime updated_at + string name + } + Setting { + string id + string value + timeDOTTime updated_at + } + Tag { + xidDOTID id + timeDOTTime created_at + string name + } + Account |o--o{ Post : "posts/author" + Account |o--o{ React : "reacts/account" + Account |o--o{ Authentication : "authentication/account" + Account }o--o{ Tag : "tags/accounts" + Account |o--o{ Collection : "collections/owner" + Account |o--o{ Cluster : "clusters/owner" + Account |o--o{ Item : "items/owner" + Account |o--o{ Asset : "assets/owner" + Category |o--o{ Post : "posts/category" + Cluster |o--o{ Cluster : "clusters/parent" + Cluster }o--o{ Item : "items/clusters" + Cluster }o--o{ Asset : "assets/clusters" + Collection }o--o{ Post : "posts/collections" + Item }o--o{ Asset : "assets/items" + Post |o--o{ Post : "posts/root" + Post |o--o{ Post : "replies/replyTo" + Post |o--o{ React : "reacts/Post" + Post }o--o{ Asset : "assets/posts" + Role }o--o{ Account : "accounts/roles" + Tag }o--o{ Post : "posts/tags" + Tag }o--o{ Cluster : "clusters/tags" + Tag }o--o{ Item : "items/tags" +
+ + + + + diff --git a/internal/ent/generate.go b/internal/ent/generate.go index 9d0776b04..b7a6f90c4 100644 --- a/internal/ent/generate.go +++ b/internal/ent/generate.go @@ -1,3 +1,4 @@ package ent //go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature sql/modifier --feature sql/upsert ./schema +//go:generate go run -mod=mod github.com/a8m/enter ./schema diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go index 729fb1f1f..2b8fe7c70 100644 --- a/internal/ent/hook/hook.go +++ b/internal/ent/hook/hook.go @@ -57,6 +57,18 @@ func (f CategoryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CategoryMutation", m) } +// The ClusterFunc type is an adapter to allow the use of ordinary +// function as Cluster mutator. +type ClusterFunc func(context.Context, *ent.ClusterMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ClusterFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ClusterMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ClusterMutation", m) +} + // The CollectionFunc type is an adapter to allow the use of ordinary // function as Collection mutator. type CollectionFunc func(context.Context, *ent.CollectionMutation) (ent.Value, error) @@ -69,6 +81,18 @@ func (f CollectionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CollectionMutation", m) } +// The ItemFunc type is an adapter to allow the use of ordinary +// function as Item mutator. +type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ItemMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m) +} + // The NotificationFunc type is an adapter to allow the use of ordinary // function as Notification mutator. type NotificationFunc func(context.Context, *ent.NotificationMutation) (ent.Value, error) diff --git a/internal/ent/item.go b/internal/ent/item.go new file mode 100644 index 000000000..7b5233f1e --- /dev/null +++ b/internal/ent/item.go @@ -0,0 +1,245 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent/dialect/sql" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/rs/xid" +) + +// Item is the model entity for the Item schema. +type Item struct { + config `json:"-"` + // ID of the ent. + ID xid.ID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Slug holds the value of the "slug" field. + Slug string `json:"slug,omitempty"` + // ImageURL holds the value of the "image_url" field. + ImageURL *string `json:"image_url,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // AccountID holds the value of the "account_id" field. + AccountID xid.ID `json:"account_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ItemQuery when eager-loading is set. + Edges ItemEdges `json:"edges"` +} + +// ItemEdges holds the relations/edges for other nodes in the graph. +type ItemEdges struct { + // Owner holds the value of the owner edge. + Owner *Account `json:"owner,omitempty"` + // Clusters holds the value of the clusters edge. + Clusters []*Cluster `json:"clusters,omitempty"` + // Assets holds the value of the assets edge. + Assets []*Asset `json:"assets,omitempty"` + // Tags holds the value of the tags edge. + Tags []*Tag `json:"tags,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// OwnerOrErr returns the Owner value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemEdges) OwnerOrErr() (*Account, error) { + if e.loadedTypes[0] { + if e.Owner == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: account.Label} + } + return e.Owner, nil + } + return nil, &NotLoadedError{edge: "owner"} +} + +// ClustersOrErr returns the Clusters value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) ClustersOrErr() ([]*Cluster, error) { + if e.loadedTypes[1] { + return e.Clusters, nil + } + return nil, &NotLoadedError{edge: "clusters"} +} + +// AssetsOrErr returns the Assets value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) AssetsOrErr() ([]*Asset, error) { + if e.loadedTypes[2] { + return e.Assets, nil + } + return nil, &NotLoadedError{edge: "assets"} +} + +// TagsOrErr returns the Tags value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) TagsOrErr() ([]*Tag, error) { + if e.loadedTypes[3] { + return e.Tags, nil + } + return nil, &NotLoadedError{edge: "tags"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Item) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case item.FieldName, item.FieldSlug, item.FieldImageURL, item.FieldDescription: + values[i] = new(sql.NullString) + case item.FieldCreatedAt, item.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case item.FieldID, item.FieldAccountID: + values[i] = new(xid.ID) + default: + return nil, fmt.Errorf("unexpected column %q for type Item", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Item fields. +func (i *Item) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for j := range columns { + switch columns[j] { + case item.FieldID: + if value, ok := values[j].(*xid.ID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[j]) + } else if value != nil { + i.ID = *value + } + case item.FieldCreatedAt: + if value, ok := values[j].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[j]) + } else if value.Valid { + i.CreatedAt = value.Time + } + case item.FieldUpdatedAt: + if value, ok := values[j].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[j]) + } else if value.Valid { + i.UpdatedAt = value.Time + } + case item.FieldName: + if value, ok := values[j].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[j]) + } else if value.Valid { + i.Name = value.String + } + case item.FieldSlug: + if value, ok := values[j].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field slug", values[j]) + } else if value.Valid { + i.Slug = value.String + } + case item.FieldImageURL: + if value, ok := values[j].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field image_url", values[j]) + } else if value.Valid { + i.ImageURL = new(string) + *i.ImageURL = value.String + } + case item.FieldDescription: + if value, ok := values[j].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[j]) + } else if value.Valid { + i.Description = value.String + } + case item.FieldAccountID: + if value, ok := values[j].(*xid.ID); !ok { + return fmt.Errorf("unexpected type %T for field account_id", values[j]) + } else if value != nil { + i.AccountID = *value + } + } + } + return nil +} + +// QueryOwner queries the "owner" edge of the Item entity. +func (i *Item) QueryOwner() *AccountQuery { + return NewItemClient(i.config).QueryOwner(i) +} + +// QueryClusters queries the "clusters" edge of the Item entity. +func (i *Item) QueryClusters() *ClusterQuery { + return NewItemClient(i.config).QueryClusters(i) +} + +// QueryAssets queries the "assets" edge of the Item entity. +func (i *Item) QueryAssets() *AssetQuery { + return NewItemClient(i.config).QueryAssets(i) +} + +// QueryTags queries the "tags" edge of the Item entity. +func (i *Item) QueryTags() *TagQuery { + return NewItemClient(i.config).QueryTags(i) +} + +// Update returns a builder for updating this Item. +// Note that you need to call Item.Unwrap() before calling this method if this Item +// was returned from a transaction, and the transaction was committed or rolled back. +func (i *Item) Update() *ItemUpdateOne { + return NewItemClient(i.config).UpdateOne(i) +} + +// Unwrap unwraps the Item entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (i *Item) Unwrap() *Item { + _tx, ok := i.config.driver.(*txDriver) + if !ok { + panic("ent: Item is not a transactional entity") + } + i.config.driver = _tx.drv + return i +} + +// String implements the fmt.Stringer. +func (i *Item) String() string { + var builder strings.Builder + builder.WriteString("Item(") + builder.WriteString(fmt.Sprintf("id=%v, ", i.ID)) + builder.WriteString("created_at=") + builder.WriteString(i.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(i.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(i.Name) + builder.WriteString(", ") + builder.WriteString("slug=") + builder.WriteString(i.Slug) + builder.WriteString(", ") + if v := i.ImageURL; v != nil { + builder.WriteString("image_url=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(i.Description) + builder.WriteString(", ") + builder.WriteString("account_id=") + builder.WriteString(fmt.Sprintf("%v", i.AccountID)) + builder.WriteByte(')') + return builder.String() +} + +// Items is a parsable slice of Item. +type Items []*Item diff --git a/internal/ent/item/item.go b/internal/ent/item/item.go new file mode 100644 index 000000000..af869c399 --- /dev/null +++ b/internal/ent/item/item.go @@ -0,0 +1,109 @@ +// Code generated by ent, DO NOT EDIT. + +package item + +import ( + "time" + + "github.com/rs/xid" +) + +const ( + // Label holds the string label denoting the item type in the database. + Label = "item" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldSlug holds the string denoting the slug field in the database. + FieldSlug = "slug" + // FieldImageURL holds the string denoting the image_url field in the database. + FieldImageURL = "image_url" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldAccountID holds the string denoting the account_id field in the database. + FieldAccountID = "account_id" + // EdgeOwner holds the string denoting the owner edge name in mutations. + EdgeOwner = "owner" + // EdgeClusters holds the string denoting the clusters edge name in mutations. + EdgeClusters = "clusters" + // EdgeAssets holds the string denoting the assets edge name in mutations. + EdgeAssets = "assets" + // EdgeTags holds the string denoting the tags edge name in mutations. + EdgeTags = "tags" + // Table holds the table name of the item in the database. + Table = "items" + // OwnerTable is the table that holds the owner relation/edge. + OwnerTable = "items" + // OwnerInverseTable is the table name for the Account entity. + // It exists in this package in order to avoid circular dependency with the "account" package. + OwnerInverseTable = "accounts" + // OwnerColumn is the table column denoting the owner relation/edge. + OwnerColumn = "account_id" + // ClustersTable is the table that holds the clusters relation/edge. The primary key declared below. + ClustersTable = "cluster_items" + // ClustersInverseTable is the table name for the Cluster entity. + // It exists in this package in order to avoid circular dependency with the "cluster" package. + ClustersInverseTable = "clusters" + // AssetsTable is the table that holds the assets relation/edge. The primary key declared below. + AssetsTable = "item_assets" + // AssetsInverseTable is the table name for the Asset entity. + // It exists in this package in order to avoid circular dependency with the "asset" package. + AssetsInverseTable = "assets" + // TagsTable is the table that holds the tags relation/edge. The primary key declared below. + TagsTable = "tag_items" + // TagsInverseTable is the table name for the Tag entity. + // It exists in this package in order to avoid circular dependency with the "tag" package. + TagsInverseTable = "tags" +) + +// Columns holds all SQL columns for item fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldName, + FieldSlug, + FieldImageURL, + FieldDescription, + FieldAccountID, +} + +var ( + // ClustersPrimaryKey and ClustersColumn2 are the table columns denoting the + // primary key for the clusters relation (M2M). + ClustersPrimaryKey = []string{"cluster_id", "item_id"} + // AssetsPrimaryKey and AssetsColumn2 are the table columns denoting the + // primary key for the assets relation (M2M). + AssetsPrimaryKey = []string{"item_id", "asset_id"} + // TagsPrimaryKey and TagsColumn2 are the table columns denoting the + // primary key for the tags relation (M2M). + TagsPrimaryKey = []string{"tag_id", "item_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() xid.ID + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(string) error +) diff --git a/internal/ent/item/where.go b/internal/ent/item/where.go new file mode 100644 index 000000000..a8ed0894e --- /dev/null +++ b/internal/ent/item/where.go @@ -0,0 +1,652 @@ +// Code generated by ent, DO NOT EDIT. + +package item + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/rs/xid" +) + +// ID filters vertices based on their ID field. +func ID(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...xid.ID) predicate.Item { + return predicate.Item(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...xid.ID) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id xid.ID) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldName, v)) +} + +// Slug applies equality check predicate on the "slug" field. It's identical to SlugEQ. +func Slug(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldSlug, v)) +} + +// ImageURL applies equality check predicate on the "image_url" field. It's identical to ImageURLEQ. +func ImageURL(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldImageURL, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldDescription, v)) +} + +// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ. +func AccountID(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldAccountID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Item { + return predicate.Item(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Item { + return predicate.Item(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Item { + return predicate.Item(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Item { + return predicate.Item(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Item { + return predicate.Item(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Item { + return predicate.Item(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Item { + return predicate.Item(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Item { + return predicate.Item(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Item { + return predicate.Item(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Item { + return predicate.Item(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Item { + return predicate.Item(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Item { + return predicate.Item(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Item { + return predicate.Item(sql.FieldContainsFold(FieldName, v)) +} + +// SlugEQ applies the EQ predicate on the "slug" field. +func SlugEQ(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldSlug, v)) +} + +// SlugNEQ applies the NEQ predicate on the "slug" field. +func SlugNEQ(v string) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldSlug, v)) +} + +// SlugIn applies the In predicate on the "slug" field. +func SlugIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldIn(FieldSlug, vs...)) +} + +// SlugNotIn applies the NotIn predicate on the "slug" field. +func SlugNotIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldSlug, vs...)) +} + +// SlugGT applies the GT predicate on the "slug" field. +func SlugGT(v string) predicate.Item { + return predicate.Item(sql.FieldGT(FieldSlug, v)) +} + +// SlugGTE applies the GTE predicate on the "slug" field. +func SlugGTE(v string) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldSlug, v)) +} + +// SlugLT applies the LT predicate on the "slug" field. +func SlugLT(v string) predicate.Item { + return predicate.Item(sql.FieldLT(FieldSlug, v)) +} + +// SlugLTE applies the LTE predicate on the "slug" field. +func SlugLTE(v string) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldSlug, v)) +} + +// SlugContains applies the Contains predicate on the "slug" field. +func SlugContains(v string) predicate.Item { + return predicate.Item(sql.FieldContains(FieldSlug, v)) +} + +// SlugHasPrefix applies the HasPrefix predicate on the "slug" field. +func SlugHasPrefix(v string) predicate.Item { + return predicate.Item(sql.FieldHasPrefix(FieldSlug, v)) +} + +// SlugHasSuffix applies the HasSuffix predicate on the "slug" field. +func SlugHasSuffix(v string) predicate.Item { + return predicate.Item(sql.FieldHasSuffix(FieldSlug, v)) +} + +// SlugEqualFold applies the EqualFold predicate on the "slug" field. +func SlugEqualFold(v string) predicate.Item { + return predicate.Item(sql.FieldEqualFold(FieldSlug, v)) +} + +// SlugContainsFold applies the ContainsFold predicate on the "slug" field. +func SlugContainsFold(v string) predicate.Item { + return predicate.Item(sql.FieldContainsFold(FieldSlug, v)) +} + +// ImageURLEQ applies the EQ predicate on the "image_url" field. +func ImageURLEQ(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldImageURL, v)) +} + +// ImageURLNEQ applies the NEQ predicate on the "image_url" field. +func ImageURLNEQ(v string) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldImageURL, v)) +} + +// ImageURLIn applies the In predicate on the "image_url" field. +func ImageURLIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldIn(FieldImageURL, vs...)) +} + +// ImageURLNotIn applies the NotIn predicate on the "image_url" field. +func ImageURLNotIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldImageURL, vs...)) +} + +// ImageURLGT applies the GT predicate on the "image_url" field. +func ImageURLGT(v string) predicate.Item { + return predicate.Item(sql.FieldGT(FieldImageURL, v)) +} + +// ImageURLGTE applies the GTE predicate on the "image_url" field. +func ImageURLGTE(v string) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldImageURL, v)) +} + +// ImageURLLT applies the LT predicate on the "image_url" field. +func ImageURLLT(v string) predicate.Item { + return predicate.Item(sql.FieldLT(FieldImageURL, v)) +} + +// ImageURLLTE applies the LTE predicate on the "image_url" field. +func ImageURLLTE(v string) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldImageURL, v)) +} + +// ImageURLContains applies the Contains predicate on the "image_url" field. +func ImageURLContains(v string) predicate.Item { + return predicate.Item(sql.FieldContains(FieldImageURL, v)) +} + +// ImageURLHasPrefix applies the HasPrefix predicate on the "image_url" field. +func ImageURLHasPrefix(v string) predicate.Item { + return predicate.Item(sql.FieldHasPrefix(FieldImageURL, v)) +} + +// ImageURLHasSuffix applies the HasSuffix predicate on the "image_url" field. +func ImageURLHasSuffix(v string) predicate.Item { + return predicate.Item(sql.FieldHasSuffix(FieldImageURL, v)) +} + +// ImageURLIsNil applies the IsNil predicate on the "image_url" field. +func ImageURLIsNil() predicate.Item { + return predicate.Item(sql.FieldIsNull(FieldImageURL)) +} + +// ImageURLNotNil applies the NotNil predicate on the "image_url" field. +func ImageURLNotNil() predicate.Item { + return predicate.Item(sql.FieldNotNull(FieldImageURL)) +} + +// ImageURLEqualFold applies the EqualFold predicate on the "image_url" field. +func ImageURLEqualFold(v string) predicate.Item { + return predicate.Item(sql.FieldEqualFold(FieldImageURL, v)) +} + +// ImageURLContainsFold applies the ContainsFold predicate on the "image_url" field. +func ImageURLContainsFold(v string) predicate.Item { + return predicate.Item(sql.FieldContainsFold(FieldImageURL, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Item { + return predicate.Item(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Item { + return predicate.Item(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Item { + return predicate.Item(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Item { + return predicate.Item(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Item { + return predicate.Item(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Item { + return predicate.Item(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Item { + return predicate.Item(sql.FieldContainsFold(FieldDescription, v)) +} + +// AccountIDEQ applies the EQ predicate on the "account_id" field. +func AccountIDEQ(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldEQ(FieldAccountID, v)) +} + +// AccountIDNEQ applies the NEQ predicate on the "account_id" field. +func AccountIDNEQ(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldNEQ(FieldAccountID, v)) +} + +// AccountIDIn applies the In predicate on the "account_id" field. +func AccountIDIn(vs ...xid.ID) predicate.Item { + return predicate.Item(sql.FieldIn(FieldAccountID, vs...)) +} + +// AccountIDNotIn applies the NotIn predicate on the "account_id" field. +func AccountIDNotIn(vs ...xid.ID) predicate.Item { + return predicate.Item(sql.FieldNotIn(FieldAccountID, vs...)) +} + +// AccountIDGT applies the GT predicate on the "account_id" field. +func AccountIDGT(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldGT(FieldAccountID, v)) +} + +// AccountIDGTE applies the GTE predicate on the "account_id" field. +func AccountIDGTE(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldGTE(FieldAccountID, v)) +} + +// AccountIDLT applies the LT predicate on the "account_id" field. +func AccountIDLT(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldLT(FieldAccountID, v)) +} + +// AccountIDLTE applies the LTE predicate on the "account_id" field. +func AccountIDLTE(v xid.ID) predicate.Item { + return predicate.Item(sql.FieldLTE(FieldAccountID, v)) +} + +// AccountIDContains applies the Contains predicate on the "account_id" field. +func AccountIDContains(v xid.ID) predicate.Item { + vc := v.String() + return predicate.Item(sql.FieldContains(FieldAccountID, vc)) +} + +// AccountIDHasPrefix applies the HasPrefix predicate on the "account_id" field. +func AccountIDHasPrefix(v xid.ID) predicate.Item { + vc := v.String() + return predicate.Item(sql.FieldHasPrefix(FieldAccountID, vc)) +} + +// AccountIDHasSuffix applies the HasSuffix predicate on the "account_id" field. +func AccountIDHasSuffix(v xid.ID) predicate.Item { + vc := v.String() + return predicate.Item(sql.FieldHasSuffix(FieldAccountID, vc)) +} + +// AccountIDEqualFold applies the EqualFold predicate on the "account_id" field. +func AccountIDEqualFold(v xid.ID) predicate.Item { + vc := v.String() + return predicate.Item(sql.FieldEqualFold(FieldAccountID, vc)) +} + +// AccountIDContainsFold applies the ContainsFold predicate on the "account_id" field. +func AccountIDContainsFold(v xid.ID) predicate.Item { + vc := v.String() + return predicate.Item(sql.FieldContainsFold(FieldAccountID, vc)) +} + +// HasOwner applies the HasEdge predicate on the "owner" edge. +func HasOwner() predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates). +func HasOwnerWith(preds ...predicate.Account) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasClusters applies the HasEdge predicate on the "clusters" edge. +func HasClusters() predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasClustersWith applies the HasEdge predicate on the "clusters" edge with a given conditions (other predicates). +func HasClustersWith(preds ...predicate.Cluster) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ClustersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAssets applies the HasEdge predicate on the "assets" edge. +func HasAssets() predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, AssetsTable, AssetsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAssetsWith applies the HasEdge predicate on the "assets" edge with a given conditions (other predicates). +func HasAssetsWith(preds ...predicate.Asset) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AssetsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, AssetsTable, AssetsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTags applies the HasEdge predicate on the "tags" edge. +func HasTags() predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates). +func HasTagsWith(preds ...predicate.Tag) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Item) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Item) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Item) predicate.Item { + return predicate.Item(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/internal/ent/item_create.go b/internal/ent/item_create.go new file mode 100644 index 000000000..2e2e21cc7 --- /dev/null +++ b/internal/ent/item_create.go @@ -0,0 +1,964 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ItemCreate is the builder for creating a Item entity. +type ItemCreate struct { + config + mutation *ItemMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (ic *ItemCreate) SetCreatedAt(t time.Time) *ItemCreate { + ic.mutation.SetCreatedAt(t) + return ic +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (ic *ItemCreate) SetNillableCreatedAt(t *time.Time) *ItemCreate { + if t != nil { + ic.SetCreatedAt(*t) + } + return ic +} + +// SetUpdatedAt sets the "updated_at" field. +func (ic *ItemCreate) SetUpdatedAt(t time.Time) *ItemCreate { + ic.mutation.SetUpdatedAt(t) + return ic +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (ic *ItemCreate) SetNillableUpdatedAt(t *time.Time) *ItemCreate { + if t != nil { + ic.SetUpdatedAt(*t) + } + return ic +} + +// SetName sets the "name" field. +func (ic *ItemCreate) SetName(s string) *ItemCreate { + ic.mutation.SetName(s) + return ic +} + +// SetSlug sets the "slug" field. +func (ic *ItemCreate) SetSlug(s string) *ItemCreate { + ic.mutation.SetSlug(s) + return ic +} + +// SetImageURL sets the "image_url" field. +func (ic *ItemCreate) SetImageURL(s string) *ItemCreate { + ic.mutation.SetImageURL(s) + return ic +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (ic *ItemCreate) SetNillableImageURL(s *string) *ItemCreate { + if s != nil { + ic.SetImageURL(*s) + } + return ic +} + +// SetDescription sets the "description" field. +func (ic *ItemCreate) SetDescription(s string) *ItemCreate { + ic.mutation.SetDescription(s) + return ic +} + +// SetAccountID sets the "account_id" field. +func (ic *ItemCreate) SetAccountID(x xid.ID) *ItemCreate { + ic.mutation.SetAccountID(x) + return ic +} + +// SetID sets the "id" field. +func (ic *ItemCreate) SetID(x xid.ID) *ItemCreate { + ic.mutation.SetID(x) + return ic +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (ic *ItemCreate) SetNillableID(x *xid.ID) *ItemCreate { + if x != nil { + ic.SetID(*x) + } + return ic +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (ic *ItemCreate) SetOwnerID(id xid.ID) *ItemCreate { + ic.mutation.SetOwnerID(id) + return ic +} + +// SetOwner sets the "owner" edge to the Account entity. +func (ic *ItemCreate) SetOwner(a *Account) *ItemCreate { + return ic.SetOwnerID(a.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (ic *ItemCreate) AddClusterIDs(ids ...xid.ID) *ItemCreate { + ic.mutation.AddClusterIDs(ids...) + return ic +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (ic *ItemCreate) AddClusters(c ...*Cluster) *ItemCreate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return ic.AddClusterIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (ic *ItemCreate) AddAssetIDs(ids ...string) *ItemCreate { + ic.mutation.AddAssetIDs(ids...) + return ic +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (ic *ItemCreate) AddAssets(a ...*Asset) *ItemCreate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return ic.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (ic *ItemCreate) AddTagIDs(ids ...xid.ID) *ItemCreate { + ic.mutation.AddTagIDs(ids...) + return ic +} + +// AddTags adds the "tags" edges to the Tag entity. +func (ic *ItemCreate) AddTags(t ...*Tag) *ItemCreate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ic.AddTagIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (ic *ItemCreate) Mutation() *ItemMutation { + return ic.mutation +} + +// Save creates the Item in the database. +func (ic *ItemCreate) Save(ctx context.Context) (*Item, error) { + ic.defaults() + return withHooks[*Item, ItemMutation](ctx, ic.sqlSave, ic.mutation, ic.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (ic *ItemCreate) SaveX(ctx context.Context) *Item { + v, err := ic.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ic *ItemCreate) Exec(ctx context.Context) error { + _, err := ic.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ic *ItemCreate) ExecX(ctx context.Context) { + if err := ic.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ic *ItemCreate) defaults() { + if _, ok := ic.mutation.CreatedAt(); !ok { + v := item.DefaultCreatedAt() + ic.mutation.SetCreatedAt(v) + } + if _, ok := ic.mutation.UpdatedAt(); !ok { + v := item.DefaultUpdatedAt() + ic.mutation.SetUpdatedAt(v) + } + if _, ok := ic.mutation.ID(); !ok { + v := item.DefaultID() + ic.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ic *ItemCreate) check() error { + if _, ok := ic.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Item.created_at"`)} + } + if _, ok := ic.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Item.updated_at"`)} + } + if _, ok := ic.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Item.name"`)} + } + if _, ok := ic.mutation.Slug(); !ok { + return &ValidationError{Name: "slug", err: errors.New(`ent: missing required field "Item.slug"`)} + } + if _, ok := ic.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Item.description"`)} + } + if _, ok := ic.mutation.AccountID(); !ok { + return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "Item.account_id"`)} + } + if v, ok := ic.mutation.ID(); ok { + if err := item.IDValidator(v.String()); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Item.id": %w`, err)} + } + } + if _, ok := ic.mutation.OwnerID(); !ok { + return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Item.owner"`)} + } + return nil +} + +func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) { + if err := ic.check(); err != nil { + return nil, err + } + _node, _spec := ic.createSpec() + if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*xid.ID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + ic.mutation.id = &_node.ID + ic.mutation.done = true + return _node, nil +} + +func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) { + var ( + _node = &Item{config: ic.config} + _spec = sqlgraph.NewCreateSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + ) + _spec.OnConflict = ic.conflict + if id, ok := ic.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := ic.mutation.CreatedAt(); ok { + _spec.SetField(item.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := ic.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := ic.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := ic.mutation.Slug(); ok { + _spec.SetField(item.FieldSlug, field.TypeString, value) + _node.Slug = value + } + if value, ok := ic.mutation.ImageURL(); ok { + _spec.SetField(item.FieldImageURL, field.TypeString, value) + _node.ImageURL = &value + } + if value, ok := ic.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + _node.Description = value + } + if nodes := ic.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.OwnerTable, + Columns: []string{item.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.AccountID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ic.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ic.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ic.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Item.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ItemUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ic *ItemCreate) OnConflict(opts ...sql.ConflictOption) *ItemUpsertOne { + ic.conflict = opts + return &ItemUpsertOne{ + create: ic, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ic *ItemCreate) OnConflictColumns(columns ...string) *ItemUpsertOne { + ic.conflict = append(ic.conflict, sql.ConflictColumns(columns...)) + return &ItemUpsertOne{ + create: ic, + } +} + +type ( + // ItemUpsertOne is the builder for "upsert"-ing + // one Item node. + ItemUpsertOne struct { + create *ItemCreate + } + + // ItemUpsert is the "OnConflict" setter. + ItemUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *ItemUpsert) SetUpdatedAt(v time.Time) *ItemUpsert { + u.Set(item.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ItemUpsert) UpdateUpdatedAt() *ItemUpsert { + u.SetExcluded(item.FieldUpdatedAt) + return u +} + +// SetName sets the "name" field. +func (u *ItemUpsert) SetName(v string) *ItemUpsert { + u.Set(item.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ItemUpsert) UpdateName() *ItemUpsert { + u.SetExcluded(item.FieldName) + return u +} + +// SetSlug sets the "slug" field. +func (u *ItemUpsert) SetSlug(v string) *ItemUpsert { + u.Set(item.FieldSlug, v) + return u +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ItemUpsert) UpdateSlug() *ItemUpsert { + u.SetExcluded(item.FieldSlug) + return u +} + +// SetImageURL sets the "image_url" field. +func (u *ItemUpsert) SetImageURL(v string) *ItemUpsert { + u.Set(item.FieldImageURL, v) + return u +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ItemUpsert) UpdateImageURL() *ItemUpsert { + u.SetExcluded(item.FieldImageURL) + return u +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ItemUpsert) ClearImageURL() *ItemUpsert { + u.SetNull(item.FieldImageURL) + return u +} + +// SetDescription sets the "description" field. +func (u *ItemUpsert) SetDescription(v string) *ItemUpsert { + u.Set(item.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ItemUpsert) UpdateDescription() *ItemUpsert { + u.SetExcluded(item.FieldDescription) + return u +} + +// SetAccountID sets the "account_id" field. +func (u *ItemUpsert) SetAccountID(v xid.ID) *ItemUpsert { + u.Set(item.FieldAccountID, v) + return u +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ItemUpsert) UpdateAccountID() *ItemUpsert { + u.SetExcluded(item.FieldAccountID) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(item.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ItemUpsertOne) UpdateNewValues() *ItemUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(item.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(item.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ItemUpsertOne) Ignore() *ItemUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ItemUpsertOne) DoNothing() *ItemUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ItemCreate.OnConflict +// documentation for more info. +func (u *ItemUpsertOne) Update(set func(*ItemUpsert)) *ItemUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ItemUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ItemUpsertOne) SetUpdatedAt(v time.Time) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateUpdatedAt() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ItemUpsertOne) SetName(v string) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateName() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateName() + }) +} + +// SetSlug sets the "slug" field. +func (u *ItemUpsertOne) SetSlug(v string) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetSlug(v) + }) +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateSlug() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateSlug() + }) +} + +// SetImageURL sets the "image_url" field. +func (u *ItemUpsertOne) SetImageURL(v string) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetImageURL(v) + }) +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateImageURL() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateImageURL() + }) +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ItemUpsertOne) ClearImageURL() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.ClearImageURL() + }) +} + +// SetDescription sets the "description" field. +func (u *ItemUpsertOne) SetDescription(v string) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateDescription() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateDescription() + }) +} + +// SetAccountID sets the "account_id" field. +func (u *ItemUpsertOne) SetAccountID(v xid.ID) *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.SetAccountID(v) + }) +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ItemUpsertOne) UpdateAccountID() *ItemUpsertOne { + return u.Update(func(s *ItemUpsert) { + s.UpdateAccountID() + }) +} + +// Exec executes the query. +func (u *ItemUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ItemCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ItemUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ItemUpsertOne) ID(ctx context.Context) (id xid.ID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ItemUpsertOne.ID is not supported by MySQL driver. Use ItemUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ItemUpsertOne) IDX(ctx context.Context) xid.ID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ItemCreateBulk is the builder for creating many Item entities in bulk. +type ItemCreateBulk struct { + config + builders []*ItemCreate + conflict []sql.ConflictOption +} + +// Save creates the Item entities in the database. +func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error) { + specs := make([]*sqlgraph.CreateSpec, len(icb.builders)) + nodes := make([]*Item, len(icb.builders)) + mutators := make([]Mutator, len(icb.builders)) + for i := range icb.builders { + func(i int, root context.Context) { + builder := icb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ItemMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, icb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = icb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, icb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, icb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (icb *ItemCreateBulk) SaveX(ctx context.Context) []*Item { + v, err := icb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (icb *ItemCreateBulk) Exec(ctx context.Context) error { + _, err := icb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (icb *ItemCreateBulk) ExecX(ctx context.Context) { + if err := icb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Item.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ItemUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (icb *ItemCreateBulk) OnConflict(opts ...sql.ConflictOption) *ItemUpsertBulk { + icb.conflict = opts + return &ItemUpsertBulk{ + create: icb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (icb *ItemCreateBulk) OnConflictColumns(columns ...string) *ItemUpsertBulk { + icb.conflict = append(icb.conflict, sql.ConflictColumns(columns...)) + return &ItemUpsertBulk{ + create: icb, + } +} + +// ItemUpsertBulk is the builder for "upsert"-ing +// a bulk of Item nodes. +type ItemUpsertBulk struct { + create *ItemCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(item.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ItemUpsertBulk) UpdateNewValues() *ItemUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(item.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(item.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Item.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ItemUpsertBulk) Ignore() *ItemUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ItemUpsertBulk) DoNothing() *ItemUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ItemCreateBulk.OnConflict +// documentation for more info. +func (u *ItemUpsertBulk) Update(set func(*ItemUpsert)) *ItemUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ItemUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ItemUpsertBulk) SetUpdatedAt(v time.Time) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateUpdatedAt() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ItemUpsertBulk) SetName(v string) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateName() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateName() + }) +} + +// SetSlug sets the "slug" field. +func (u *ItemUpsertBulk) SetSlug(v string) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetSlug(v) + }) +} + +// UpdateSlug sets the "slug" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateSlug() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateSlug() + }) +} + +// SetImageURL sets the "image_url" field. +func (u *ItemUpsertBulk) SetImageURL(v string) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetImageURL(v) + }) +} + +// UpdateImageURL sets the "image_url" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateImageURL() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateImageURL() + }) +} + +// ClearImageURL clears the value of the "image_url" field. +func (u *ItemUpsertBulk) ClearImageURL() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.ClearImageURL() + }) +} + +// SetDescription sets the "description" field. +func (u *ItemUpsertBulk) SetDescription(v string) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateDescription() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateDescription() + }) +} + +// SetAccountID sets the "account_id" field. +func (u *ItemUpsertBulk) SetAccountID(v xid.ID) *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.SetAccountID(v) + }) +} + +// UpdateAccountID sets the "account_id" field to the value that was provided on create. +func (u *ItemUpsertBulk) UpdateAccountID() *ItemUpsertBulk { + return u.Update(func(s *ItemUpsert) { + s.UpdateAccountID() + }) +} + +// Exec executes the query. +func (u *ItemUpsertBulk) Exec(ctx context.Context) error { + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ItemCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ItemCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ItemUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/item_delete.go b/internal/ent/item_delete.go new file mode 100644 index 000000000..2ccb92998 --- /dev/null +++ b/internal/ent/item_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/predicate" +) + +// ItemDelete is the builder for deleting a Item entity. +type ItemDelete struct { + config + hooks []Hook + mutation *ItemMutation +} + +// Where appends a list predicates to the ItemDelete builder. +func (id *ItemDelete) Where(ps ...predicate.Item) *ItemDelete { + id.mutation.Where(ps...) + return id +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (id *ItemDelete) Exec(ctx context.Context) (int, error) { + return withHooks[int, ItemMutation](ctx, id.sqlExec, id.mutation, id.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (id *ItemDelete) ExecX(ctx context.Context) int { + n, err := id.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (id *ItemDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + if ps := id.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, id.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + id.mutation.done = true + return affected, err +} + +// ItemDeleteOne is the builder for deleting a single Item entity. +type ItemDeleteOne struct { + id *ItemDelete +} + +// Where appends a list predicates to the ItemDelete builder. +func (ido *ItemDeleteOne) Where(ps ...predicate.Item) *ItemDeleteOne { + ido.id.mutation.Where(ps...) + return ido +} + +// Exec executes the deletion query. +func (ido *ItemDeleteOne) Exec(ctx context.Context) error { + n, err := ido.id.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{item.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ido *ItemDeleteOne) ExecX(ctx context.Context) { + if err := ido.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/item_query.go b/internal/ent/item_query.go new file mode 100644 index 000000000..9e3aacb7b --- /dev/null +++ b/internal/ent/item_query.go @@ -0,0 +1,941 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ItemQuery is the builder for querying Item entities. +type ItemQuery struct { + config + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Item + withOwner *AccountQuery + withClusters *ClusterQuery + withAssets *AssetQuery + withTags *TagQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ItemQuery builder. +func (iq *ItemQuery) Where(ps ...predicate.Item) *ItemQuery { + iq.predicates = append(iq.predicates, ps...) + return iq +} + +// Limit the number of records to be returned by this query. +func (iq *ItemQuery) Limit(limit int) *ItemQuery { + iq.ctx.Limit = &limit + return iq +} + +// Offset to start from. +func (iq *ItemQuery) Offset(offset int) *ItemQuery { + iq.ctx.Offset = &offset + return iq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (iq *ItemQuery) Unique(unique bool) *ItemQuery { + iq.ctx.Unique = &unique + return iq +} + +// Order specifies how the records should be ordered. +func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery { + iq.order = append(iq.order, o...) + return iq +} + +// QueryOwner chains the current query on the "owner" edge. +func (iq *ItemQuery) QueryOwner() *AccountQuery { + query := (&AccountClient{config: iq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := iq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := iq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(account.Table, account.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.OwnerTable, item.OwnerColumn), + ) + fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryClusters chains the current query on the "clusters" edge. +func (iq *ItemQuery) QueryClusters() *ClusterQuery { + query := (&ClusterClient{config: iq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := iq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := iq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.ClustersTable, item.ClustersPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAssets chains the current query on the "assets" edge. +func (iq *ItemQuery) QueryAssets() *AssetQuery { + query := (&AssetClient{config: iq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := iq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := iq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, item.AssetsTable, item.AssetsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTags chains the current query on the "tags" edge. +func (iq *ItemQuery) QueryTags() *TagQuery { + query := (&TagClient{config: iq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := iq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := iq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.TagsTable, item.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Item entity from the query. +// Returns a *NotFoundError when no Item was found. +func (iq *ItemQuery) First(ctx context.Context) (*Item, error) { + nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{item.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (iq *ItemQuery) FirstX(ctx context.Context) *Item { + node, err := iq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Item ID from the query. +// Returns a *NotFoundError when no Item ID was found. +func (iq *ItemQuery) FirstID(ctx context.Context) (id xid.ID, err error) { + var ids []xid.ID + if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{item.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (iq *ItemQuery) FirstIDX(ctx context.Context) xid.ID { + id, err := iq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Item entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Item entity is found. +// Returns a *NotFoundError when no Item entities are found. +func (iq *ItemQuery) Only(ctx context.Context) (*Item, error) { + nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{item.Label} + default: + return nil, &NotSingularError{item.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (iq *ItemQuery) OnlyX(ctx context.Context) *Item { + node, err := iq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Item ID in the query. +// Returns a *NotSingularError when more than one Item ID is found. +// Returns a *NotFoundError when no entities are found. +func (iq *ItemQuery) OnlyID(ctx context.Context) (id xid.ID, err error) { + var ids []xid.ID + if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{item.Label} + default: + err = &NotSingularError{item.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (iq *ItemQuery) OnlyIDX(ctx context.Context) xid.ID { + id, err := iq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Items. +func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error) { + ctx = setContextOp(ctx, iq.ctx, "All") + if err := iq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Item, *ItemQuery]() + return withInterceptors[[]*Item](ctx, iq, qr, iq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (iq *ItemQuery) AllX(ctx context.Context) []*Item { + nodes, err := iq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Item IDs. +func (iq *ItemQuery) IDs(ctx context.Context) (ids []xid.ID, err error) { + if iq.ctx.Unique == nil && iq.path != nil { + iq.Unique(true) + } + ctx = setContextOp(ctx, iq.ctx, "IDs") + if err = iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (iq *ItemQuery) IDsX(ctx context.Context) []xid.ID { + ids, err := iq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (iq *ItemQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, iq.ctx, "Count") + if err := iq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, iq, querierCount[*ItemQuery](), iq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (iq *ItemQuery) CountX(ctx context.Context) int { + count, err := iq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (iq *ItemQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, iq.ctx, "Exist") + switch _, err := iq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (iq *ItemQuery) ExistX(ctx context.Context) bool { + exist, err := iq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ItemQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (iq *ItemQuery) Clone() *ItemQuery { + if iq == nil { + return nil + } + return &ItemQuery{ + config: iq.config, + ctx: iq.ctx.Clone(), + order: append([]OrderFunc{}, iq.order...), + inters: append([]Interceptor{}, iq.inters...), + predicates: append([]predicate.Item{}, iq.predicates...), + withOwner: iq.withOwner.Clone(), + withClusters: iq.withClusters.Clone(), + withAssets: iq.withAssets.Clone(), + withTags: iq.withTags.Clone(), + // clone intermediate query. + sql: iq.sql.Clone(), + path: iq.path, + } +} + +// WithOwner tells the query-builder to eager-load the nodes that are connected to +// the "owner" edge. The optional arguments are used to configure the query builder of the edge. +func (iq *ItemQuery) WithOwner(opts ...func(*AccountQuery)) *ItemQuery { + query := (&AccountClient{config: iq.config}).Query() + for _, opt := range opts { + opt(query) + } + iq.withOwner = query + return iq +} + +// WithClusters tells the query-builder to eager-load the nodes that are connected to +// the "clusters" edge. The optional arguments are used to configure the query builder of the edge. +func (iq *ItemQuery) WithClusters(opts ...func(*ClusterQuery)) *ItemQuery { + query := (&ClusterClient{config: iq.config}).Query() + for _, opt := range opts { + opt(query) + } + iq.withClusters = query + return iq +} + +// WithAssets tells the query-builder to eager-load the nodes that are connected to +// the "assets" edge. The optional arguments are used to configure the query builder of the edge. +func (iq *ItemQuery) WithAssets(opts ...func(*AssetQuery)) *ItemQuery { + query := (&AssetClient{config: iq.config}).Query() + for _, opt := range opts { + opt(query) + } + iq.withAssets = query + return iq +} + +// WithTags tells the query-builder to eager-load the nodes that are connected to +// the "tags" edge. The optional arguments are used to configure the query builder of the edge. +func (iq *ItemQuery) WithTags(opts ...func(*TagQuery)) *ItemQuery { + query := (&TagClient{config: iq.config}).Query() + for _, opt := range opts { + opt(query) + } + iq.withTags = query + return iq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Item.Query(). +// GroupBy(item.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy { + iq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ItemGroupBy{build: iq} + grbuild.flds = &iq.ctx.Fields + grbuild.label = item.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Item.Query(). +// Select(item.FieldCreatedAt). +// Scan(ctx, &v) +func (iq *ItemQuery) Select(fields ...string) *ItemSelect { + iq.ctx.Fields = append(iq.ctx.Fields, fields...) + sbuild := &ItemSelect{ItemQuery: iq} + sbuild.label = item.Label + sbuild.flds, sbuild.scan = &iq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ItemSelect configured with the given aggregations. +func (iq *ItemQuery) Aggregate(fns ...AggregateFunc) *ItemSelect { + return iq.Select().Aggregate(fns...) +} + +func (iq *ItemQuery) prepareQuery(ctx context.Context) error { + for _, inter := range iq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, iq); err != nil { + return err + } + } + } + for _, f := range iq.ctx.Fields { + if !item.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if iq.path != nil { + prev, err := iq.path(ctx) + if err != nil { + return err + } + iq.sql = prev + } + return nil +} + +func (iq *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, error) { + var ( + nodes = []*Item{} + _spec = iq.querySpec() + loadedTypes = [4]bool{ + iq.withOwner != nil, + iq.withClusters != nil, + iq.withAssets != nil, + iq.withTags != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Item).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Item{config: iq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(iq.modifiers) > 0 { + _spec.Modifiers = iq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, iq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := iq.withOwner; query != nil { + if err := iq.loadOwner(ctx, query, nodes, nil, + func(n *Item, e *Account) { n.Edges.Owner = e }); err != nil { + return nil, err + } + } + if query := iq.withClusters; query != nil { + if err := iq.loadClusters(ctx, query, nodes, + func(n *Item) { n.Edges.Clusters = []*Cluster{} }, + func(n *Item, e *Cluster) { n.Edges.Clusters = append(n.Edges.Clusters, e) }); err != nil { + return nil, err + } + } + if query := iq.withAssets; query != nil { + if err := iq.loadAssets(ctx, query, nodes, + func(n *Item) { n.Edges.Assets = []*Asset{} }, + func(n *Item, e *Asset) { n.Edges.Assets = append(n.Edges.Assets, e) }); err != nil { + return nil, err + } + } + if query := iq.withTags; query != nil { + if err := iq.loadTags(ctx, query, nodes, + func(n *Item) { n.Edges.Tags = []*Tag{} }, + func(n *Item, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (iq *ItemQuery) loadOwner(ctx context.Context, query *AccountQuery, nodes []*Item, init func(*Item), assign func(*Item, *Account)) error { + ids := make([]xid.ID, 0, len(nodes)) + nodeids := make(map[xid.ID][]*Item) + for i := range nodes { + fk := nodes[i].AccountID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(account.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "account_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (iq *ItemQuery) loadClusters(ctx context.Context, query *ClusterQuery, nodes []*Item, init func(*Item), assign func(*Item, *Cluster)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Item) + nids := make(map[xid.ID]map[*Item]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(item.ClustersTable) + s.Join(joinT).On(s.C(cluster.FieldID), joinT.C(item.ClustersPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(item.ClustersPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(item.ClustersPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Item]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Cluster](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "clusters" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (iq *ItemQuery) loadAssets(ctx context.Context, query *AssetQuery, nodes []*Item, init func(*Item), assign func(*Item, *Asset)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Item) + nids := make(map[string]map[*Item]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(item.AssetsTable) + s.Join(joinT).On(s.C(asset.FieldID), joinT.C(item.AssetsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(item.AssetsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(item.AssetsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Item]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Asset](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "assets" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (iq *ItemQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Item, init func(*Item), assign func(*Item, *Tag)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Item) + nids := make(map[xid.ID]map[*Item]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(item.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(item.TagsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(item.TagsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(item.TagsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Item]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (iq *ItemQuery) sqlCount(ctx context.Context) (int, error) { + _spec := iq.querySpec() + if len(iq.modifiers) > 0 { + _spec.Modifiers = iq.modifiers + } + _spec.Node.Columns = iq.ctx.Fields + if len(iq.ctx.Fields) > 0 { + _spec.Unique = iq.ctx.Unique != nil && *iq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, iq.driver, _spec) +} + +func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + _spec.From = iq.sql + if unique := iq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if iq.path != nil { + _spec.Unique = true + } + if fields := iq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, item.FieldID) + for i := range fields { + if fields[i] != item.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := iq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := iq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := iq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := iq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (iq *ItemQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(iq.driver.Dialect()) + t1 := builder.Table(item.Table) + columns := iq.ctx.Fields + if len(columns) == 0 { + columns = item.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if iq.sql != nil { + selector = iq.sql + selector.Select(selector.Columns(columns...)...) + } + if iq.ctx.Unique != nil && *iq.ctx.Unique { + selector.Distinct() + } + for _, m := range iq.modifiers { + m(selector) + } + for _, p := range iq.predicates { + p(selector) + } + for _, p := range iq.order { + p(selector) + } + if offset := iq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := iq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (iq *ItemQuery) Modify(modifiers ...func(s *sql.Selector)) *ItemSelect { + iq.modifiers = append(iq.modifiers, modifiers...) + return iq.Select() +} + +// ItemGroupBy is the group-by builder for Item entities. +type ItemGroupBy struct { + selector + build *ItemQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (igb *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy { + igb.fns = append(igb.fns, fns...) + return igb +} + +// Scan applies the selector query and scans the result into the given value. +func (igb *ItemGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, igb.build.ctx, "GroupBy") + if err := igb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemQuery, *ItemGroupBy](ctx, igb.build, igb, igb.build.inters, v) +} + +func (igb *ItemGroupBy) sqlScan(ctx context.Context, root *ItemQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(igb.fns)) + for _, fn := range igb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*igb.flds)+len(igb.fns)) + for _, f := range *igb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*igb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := igb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ItemSelect is the builder for selecting fields of Item entities. +type ItemSelect struct { + *ItemQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (is *ItemSelect) Aggregate(fns ...AggregateFunc) *ItemSelect { + is.fns = append(is.fns, fns...) + return is +} + +// Scan applies the selector query and scans the result into the given value. +func (is *ItemSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, is.ctx, "Select") + if err := is.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemQuery, *ItemSelect](ctx, is.ItemQuery, is, is.inters, v) +} + +func (is *ItemSelect) sqlScan(ctx context.Context, root *ItemQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(is.fns)) + for _, fn := range is.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*is.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := is.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (is *ItemSelect) Modify(modifiers ...func(s *sql.Selector)) *ItemSelect { + is.modifiers = append(is.modifiers, modifiers...) + return is +} diff --git a/internal/ent/item_update.go b/internal/ent/item_update.go new file mode 100644 index 000000000..3ce47900a --- /dev/null +++ b/internal/ent/item_update.go @@ -0,0 +1,951 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/asset" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" + "github.com/Southclaws/storyden/internal/ent/predicate" + "github.com/Southclaws/storyden/internal/ent/tag" + "github.com/rs/xid" +) + +// ItemUpdate is the builder for updating Item entities. +type ItemUpdate struct { + config + hooks []Hook + mutation *ItemMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ItemUpdate builder. +func (iu *ItemUpdate) Where(ps ...predicate.Item) *ItemUpdate { + iu.mutation.Where(ps...) + return iu +} + +// SetUpdatedAt sets the "updated_at" field. +func (iu *ItemUpdate) SetUpdatedAt(t time.Time) *ItemUpdate { + iu.mutation.SetUpdatedAt(t) + return iu +} + +// SetName sets the "name" field. +func (iu *ItemUpdate) SetName(s string) *ItemUpdate { + iu.mutation.SetName(s) + return iu +} + +// SetSlug sets the "slug" field. +func (iu *ItemUpdate) SetSlug(s string) *ItemUpdate { + iu.mutation.SetSlug(s) + return iu +} + +// SetImageURL sets the "image_url" field. +func (iu *ItemUpdate) SetImageURL(s string) *ItemUpdate { + iu.mutation.SetImageURL(s) + return iu +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (iu *ItemUpdate) SetNillableImageURL(s *string) *ItemUpdate { + if s != nil { + iu.SetImageURL(*s) + } + return iu +} + +// ClearImageURL clears the value of the "image_url" field. +func (iu *ItemUpdate) ClearImageURL() *ItemUpdate { + iu.mutation.ClearImageURL() + return iu +} + +// SetDescription sets the "description" field. +func (iu *ItemUpdate) SetDescription(s string) *ItemUpdate { + iu.mutation.SetDescription(s) + return iu +} + +// SetAccountID sets the "account_id" field. +func (iu *ItemUpdate) SetAccountID(x xid.ID) *ItemUpdate { + iu.mutation.SetAccountID(x) + return iu +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (iu *ItemUpdate) SetOwnerID(id xid.ID) *ItemUpdate { + iu.mutation.SetOwnerID(id) + return iu +} + +// SetOwner sets the "owner" edge to the Account entity. +func (iu *ItemUpdate) SetOwner(a *Account) *ItemUpdate { + return iu.SetOwnerID(a.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (iu *ItemUpdate) AddClusterIDs(ids ...xid.ID) *ItemUpdate { + iu.mutation.AddClusterIDs(ids...) + return iu +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (iu *ItemUpdate) AddClusters(c ...*Cluster) *ItemUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return iu.AddClusterIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (iu *ItemUpdate) AddAssetIDs(ids ...string) *ItemUpdate { + iu.mutation.AddAssetIDs(ids...) + return iu +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (iu *ItemUpdate) AddAssets(a ...*Asset) *ItemUpdate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return iu.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (iu *ItemUpdate) AddTagIDs(ids ...xid.ID) *ItemUpdate { + iu.mutation.AddTagIDs(ids...) + return iu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (iu *ItemUpdate) AddTags(t ...*Tag) *ItemUpdate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return iu.AddTagIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (iu *ItemUpdate) Mutation() *ItemMutation { + return iu.mutation +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (iu *ItemUpdate) ClearOwner() *ItemUpdate { + iu.mutation.ClearOwner() + return iu +} + +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (iu *ItemUpdate) ClearClusters() *ItemUpdate { + iu.mutation.ClearClusters() + return iu +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (iu *ItemUpdate) RemoveClusterIDs(ids ...xid.ID) *ItemUpdate { + iu.mutation.RemoveClusterIDs(ids...) + return iu +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (iu *ItemUpdate) RemoveClusters(c ...*Cluster) *ItemUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return iu.RemoveClusterIDs(ids...) +} + +// ClearAssets clears all "assets" edges to the Asset entity. +func (iu *ItemUpdate) ClearAssets() *ItemUpdate { + iu.mutation.ClearAssets() + return iu +} + +// RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. +func (iu *ItemUpdate) RemoveAssetIDs(ids ...string) *ItemUpdate { + iu.mutation.RemoveAssetIDs(ids...) + return iu +} + +// RemoveAssets removes "assets" edges to Asset entities. +func (iu *ItemUpdate) RemoveAssets(a ...*Asset) *ItemUpdate { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return iu.RemoveAssetIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (iu *ItemUpdate) ClearTags() *ItemUpdate { + iu.mutation.ClearTags() + return iu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (iu *ItemUpdate) RemoveTagIDs(ids ...xid.ID) *ItemUpdate { + iu.mutation.RemoveTagIDs(ids...) + return iu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (iu *ItemUpdate) RemoveTags(t ...*Tag) *ItemUpdate { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return iu.RemoveTagIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (iu *ItemUpdate) Save(ctx context.Context) (int, error) { + iu.defaults() + return withHooks[int, ItemMutation](ctx, iu.sqlSave, iu.mutation, iu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (iu *ItemUpdate) SaveX(ctx context.Context) int { + affected, err := iu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (iu *ItemUpdate) Exec(ctx context.Context) error { + _, err := iu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (iu *ItemUpdate) ExecX(ctx context.Context) { + if err := iu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (iu *ItemUpdate) defaults() { + if _, ok := iu.mutation.UpdatedAt(); !ok { + v := item.UpdateDefaultUpdatedAt() + iu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (iu *ItemUpdate) check() error { + if _, ok := iu.mutation.OwnerID(); iu.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Item.owner"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (iu *ItemUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ItemUpdate { + iu.modifiers = append(iu.modifiers, modifiers...) + return iu +} + +func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := iu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + if ps := iu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := iu.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := iu.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + } + if value, ok := iu.mutation.Slug(); ok { + _spec.SetField(item.FieldSlug, field.TypeString, value) + } + if value, ok := iu.mutation.ImageURL(); ok { + _spec.SetField(item.FieldImageURL, field.TypeString, value) + } + if iu.mutation.ImageURLCleared() { + _spec.ClearField(item.FieldImageURL, field.TypeString) + } + if value, ok := iu.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + } + if iu.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.OwnerTable, + Columns: []string{item.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.OwnerTable, + Columns: []string{item.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.RemovedClustersIDs(); len(nodes) > 0 && !iu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iu.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !iu.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.RemovedTagsIDs(); len(nodes) > 0 && !iu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iu.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(iu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{item.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + iu.mutation.done = true + return n, nil +} + +// ItemUpdateOne is the builder for updating a single Item entity. +type ItemUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ItemMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (iuo *ItemUpdateOne) SetUpdatedAt(t time.Time) *ItemUpdateOne { + iuo.mutation.SetUpdatedAt(t) + return iuo +} + +// SetName sets the "name" field. +func (iuo *ItemUpdateOne) SetName(s string) *ItemUpdateOne { + iuo.mutation.SetName(s) + return iuo +} + +// SetSlug sets the "slug" field. +func (iuo *ItemUpdateOne) SetSlug(s string) *ItemUpdateOne { + iuo.mutation.SetSlug(s) + return iuo +} + +// SetImageURL sets the "image_url" field. +func (iuo *ItemUpdateOne) SetImageURL(s string) *ItemUpdateOne { + iuo.mutation.SetImageURL(s) + return iuo +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (iuo *ItemUpdateOne) SetNillableImageURL(s *string) *ItemUpdateOne { + if s != nil { + iuo.SetImageURL(*s) + } + return iuo +} + +// ClearImageURL clears the value of the "image_url" field. +func (iuo *ItemUpdateOne) ClearImageURL() *ItemUpdateOne { + iuo.mutation.ClearImageURL() + return iuo +} + +// SetDescription sets the "description" field. +func (iuo *ItemUpdateOne) SetDescription(s string) *ItemUpdateOne { + iuo.mutation.SetDescription(s) + return iuo +} + +// SetAccountID sets the "account_id" field. +func (iuo *ItemUpdateOne) SetAccountID(x xid.ID) *ItemUpdateOne { + iuo.mutation.SetAccountID(x) + return iuo +} + +// SetOwnerID sets the "owner" edge to the Account entity by ID. +func (iuo *ItemUpdateOne) SetOwnerID(id xid.ID) *ItemUpdateOne { + iuo.mutation.SetOwnerID(id) + return iuo +} + +// SetOwner sets the "owner" edge to the Account entity. +func (iuo *ItemUpdateOne) SetOwner(a *Account) *ItemUpdateOne { + return iuo.SetOwnerID(a.ID) +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (iuo *ItemUpdateOne) AddClusterIDs(ids ...xid.ID) *ItemUpdateOne { + iuo.mutation.AddClusterIDs(ids...) + return iuo +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (iuo *ItemUpdateOne) AddClusters(c ...*Cluster) *ItemUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return iuo.AddClusterIDs(ids...) +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by IDs. +func (iuo *ItemUpdateOne) AddAssetIDs(ids ...string) *ItemUpdateOne { + iuo.mutation.AddAssetIDs(ids...) + return iuo +} + +// AddAssets adds the "assets" edges to the Asset entity. +func (iuo *ItemUpdateOne) AddAssets(a ...*Asset) *ItemUpdateOne { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return iuo.AddAssetIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (iuo *ItemUpdateOne) AddTagIDs(ids ...xid.ID) *ItemUpdateOne { + iuo.mutation.AddTagIDs(ids...) + return iuo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (iuo *ItemUpdateOne) AddTags(t ...*Tag) *ItemUpdateOne { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return iuo.AddTagIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (iuo *ItemUpdateOne) Mutation() *ItemMutation { + return iuo.mutation +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (iuo *ItemUpdateOne) ClearOwner() *ItemUpdateOne { + iuo.mutation.ClearOwner() + return iuo +} + +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (iuo *ItemUpdateOne) ClearClusters() *ItemUpdateOne { + iuo.mutation.ClearClusters() + return iuo +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (iuo *ItemUpdateOne) RemoveClusterIDs(ids ...xid.ID) *ItemUpdateOne { + iuo.mutation.RemoveClusterIDs(ids...) + return iuo +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (iuo *ItemUpdateOne) RemoveClusters(c ...*Cluster) *ItemUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return iuo.RemoveClusterIDs(ids...) +} + +// ClearAssets clears all "assets" edges to the Asset entity. +func (iuo *ItemUpdateOne) ClearAssets() *ItemUpdateOne { + iuo.mutation.ClearAssets() + return iuo +} + +// RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. +func (iuo *ItemUpdateOne) RemoveAssetIDs(ids ...string) *ItemUpdateOne { + iuo.mutation.RemoveAssetIDs(ids...) + return iuo +} + +// RemoveAssets removes "assets" edges to Asset entities. +func (iuo *ItemUpdateOne) RemoveAssets(a ...*Asset) *ItemUpdateOne { + ids := make([]string, len(a)) + for i := range a { + ids[i] = a[i].ID + } + return iuo.RemoveAssetIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (iuo *ItemUpdateOne) ClearTags() *ItemUpdateOne { + iuo.mutation.ClearTags() + return iuo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (iuo *ItemUpdateOne) RemoveTagIDs(ids ...xid.ID) *ItemUpdateOne { + iuo.mutation.RemoveTagIDs(ids...) + return iuo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (iuo *ItemUpdateOne) RemoveTags(t ...*Tag) *ItemUpdateOne { + ids := make([]xid.ID, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return iuo.RemoveTagIDs(ids...) +} + +// Where appends a list predicates to the ItemUpdate builder. +func (iuo *ItemUpdateOne) Where(ps ...predicate.Item) *ItemUpdateOne { + iuo.mutation.Where(ps...) + return iuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (iuo *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne { + iuo.fields = append([]string{field}, fields...) + return iuo +} + +// Save executes the query and returns the updated Item entity. +func (iuo *ItemUpdateOne) Save(ctx context.Context) (*Item, error) { + iuo.defaults() + return withHooks[*Item, ItemMutation](ctx, iuo.sqlSave, iuo.mutation, iuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (iuo *ItemUpdateOne) SaveX(ctx context.Context) *Item { + node, err := iuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (iuo *ItemUpdateOne) Exec(ctx context.Context) error { + _, err := iuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (iuo *ItemUpdateOne) ExecX(ctx context.Context) { + if err := iuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (iuo *ItemUpdateOne) defaults() { + if _, ok := iuo.mutation.UpdatedAt(); !ok { + v := item.UpdateDefaultUpdatedAt() + iuo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (iuo *ItemUpdateOne) check() error { + if _, ok := iuo.mutation.OwnerID(); iuo.mutation.OwnerCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Item.owner"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (iuo *ItemUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ItemUpdateOne { + iuo.modifiers = append(iuo.modifiers, modifiers...) + return iuo +} + +func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) { + if err := iuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + id, ok := iuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Item.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := iuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, item.FieldID) + for _, f := range fields { + if !item.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != item.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := iuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := iuo.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := iuo.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + } + if value, ok := iuo.mutation.Slug(); ok { + _spec.SetField(item.FieldSlug, field.TypeString, value) + } + if value, ok := iuo.mutation.ImageURL(); ok { + _spec.SetField(item.FieldImageURL, field.TypeString, value) + } + if iuo.mutation.ImageURLCleared() { + _spec.ClearField(item.FieldImageURL, field.TypeString) + } + if value, ok := iuo.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + } + if iuo.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.OwnerTable, + Columns: []string{item.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.OwnerTable, + Columns: []string{item.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.RemovedClustersIDs(); len(nodes) > 0 && !iuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.ClustersTable, + Columns: item.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iuo.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !iuo.mutation.AssetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.AssetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: item.AssetsTable, + Columns: item.AssetsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if iuo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !iuo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := iuo.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.TagsTable, + Columns: item.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(iuo.modifiers...) + _node = &Item{config: iuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, iuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{item.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + iuo.mutation.done = true + return _node, nil +} diff --git a/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go index 3586790ea..379cf1f5b 100644 --- a/internal/ent/migrate/schema.go +++ b/internal/ent/migrate/schema.go @@ -100,6 +100,38 @@ var ( Columns: CategoriesColumns, PrimaryKey: []*schema.Column{CategoriesColumns[0]}, } + // ClustersColumns holds the columns for the "clusters" table. + ClustersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, Size: 20}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString}, + {Name: "slug", Type: field.TypeString}, + {Name: "image_url", Type: field.TypeString, Nullable: true}, + {Name: "description", Type: field.TypeString}, + {Name: "account_id", Type: field.TypeString, Size: 20}, + {Name: "parent_cluster_id", Type: field.TypeString, Nullable: true, Size: 20}, + } + // ClustersTable holds the schema information for the "clusters" table. + ClustersTable = &schema.Table{ + Name: "clusters", + Columns: ClustersColumns, + PrimaryKey: []*schema.Column{ClustersColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "clusters_accounts_clusters", + Columns: []*schema.Column{ClustersColumns[7]}, + RefColumns: []*schema.Column{AccountsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "clusters_clusters_clusters", + Columns: []*schema.Column{ClustersColumns[8]}, + RefColumns: []*schema.Column{ClustersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } // CollectionsColumns holds the columns for the "collections" table. CollectionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Size: 20}, @@ -123,6 +155,31 @@ var ( }, }, } + // ItemsColumns holds the columns for the "items" table. + ItemsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, Size: 20}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString}, + {Name: "slug", Type: field.TypeString}, + {Name: "image_url", Type: field.TypeString, Nullable: true}, + {Name: "description", Type: field.TypeString}, + {Name: "account_id", Type: field.TypeString, Size: 20}, + } + // ItemsTable holds the schema information for the "items" table. + ItemsTable = &schema.Table{ + Name: "items", + Columns: ItemsColumns, + PrimaryKey: []*schema.Column{ItemsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "items_accounts_items", + Columns: []*schema.Column{ItemsColumns[7]}, + RefColumns: []*schema.Column{AccountsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } // NotificationsColumns holds the columns for the "notifications" table. NotificationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Size: 20}, @@ -280,6 +337,56 @@ var ( }, }, } + // ClusterItemsColumns holds the columns for the "cluster_items" table. + ClusterItemsColumns = []*schema.Column{ + {Name: "cluster_id", Type: field.TypeString, Size: 20}, + {Name: "item_id", Type: field.TypeString, Size: 20}, + } + // ClusterItemsTable holds the schema information for the "cluster_items" table. + ClusterItemsTable = &schema.Table{ + Name: "cluster_items", + Columns: ClusterItemsColumns, + PrimaryKey: []*schema.Column{ClusterItemsColumns[0], ClusterItemsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "cluster_items_cluster_id", + Columns: []*schema.Column{ClusterItemsColumns[0]}, + RefColumns: []*schema.Column{ClustersColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "cluster_items_item_id", + Columns: []*schema.Column{ClusterItemsColumns[1]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // ClusterAssetsColumns holds the columns for the "cluster_assets" table. + ClusterAssetsColumns = []*schema.Column{ + {Name: "cluster_id", Type: field.TypeString, Size: 20}, + {Name: "asset_id", Type: field.TypeString}, + } + // ClusterAssetsTable holds the schema information for the "cluster_assets" table. + ClusterAssetsTable = &schema.Table{ + Name: "cluster_assets", + Columns: ClusterAssetsColumns, + PrimaryKey: []*schema.Column{ClusterAssetsColumns[0], ClusterAssetsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "cluster_assets_cluster_id", + Columns: []*schema.Column{ClusterAssetsColumns[0]}, + RefColumns: []*schema.Column{ClustersColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "cluster_assets_asset_id", + Columns: []*schema.Column{ClusterAssetsColumns[1]}, + RefColumns: []*schema.Column{AssetsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // CollectionPostsColumns holds the columns for the "collection_posts" table. CollectionPostsColumns = []*schema.Column{ {Name: "collection_id", Type: field.TypeString, Size: 20}, @@ -305,6 +412,31 @@ var ( }, }, } + // ItemAssetsColumns holds the columns for the "item_assets" table. + ItemAssetsColumns = []*schema.Column{ + {Name: "item_id", Type: field.TypeString, Size: 20}, + {Name: "asset_id", Type: field.TypeString}, + } + // ItemAssetsTable holds the schema information for the "item_assets" table. + ItemAssetsTable = &schema.Table{ + Name: "item_assets", + Columns: ItemAssetsColumns, + PrimaryKey: []*schema.Column{ItemAssetsColumns[0], ItemAssetsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "item_assets_item_id", + Columns: []*schema.Column{ItemAssetsColumns[0]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "item_assets_asset_id", + Columns: []*schema.Column{ItemAssetsColumns[1]}, + RefColumns: []*schema.Column{AssetsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // PostAssetsColumns holds the columns for the "post_assets" table. PostAssetsColumns = []*schema.Column{ {Name: "post_id", Type: field.TypeString, Size: 20}, @@ -380,13 +512,65 @@ var ( }, }, } + // TagClustersColumns holds the columns for the "tag_clusters" table. + TagClustersColumns = []*schema.Column{ + {Name: "tag_id", Type: field.TypeString, Size: 20}, + {Name: "cluster_id", Type: field.TypeString, Size: 20}, + } + // TagClustersTable holds the schema information for the "tag_clusters" table. + TagClustersTable = &schema.Table{ + Name: "tag_clusters", + Columns: TagClustersColumns, + PrimaryKey: []*schema.Column{TagClustersColumns[0], TagClustersColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "tag_clusters_tag_id", + Columns: []*schema.Column{TagClustersColumns[0]}, + RefColumns: []*schema.Column{TagsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "tag_clusters_cluster_id", + Columns: []*schema.Column{TagClustersColumns[1]}, + RefColumns: []*schema.Column{ClustersColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // TagItemsColumns holds the columns for the "tag_items" table. + TagItemsColumns = []*schema.Column{ + {Name: "tag_id", Type: field.TypeString, Size: 20}, + {Name: "item_id", Type: field.TypeString, Size: 20}, + } + // TagItemsTable holds the schema information for the "tag_items" table. + TagItemsTable = &schema.Table{ + Name: "tag_items", + Columns: TagItemsColumns, + PrimaryKey: []*schema.Column{TagItemsColumns[0], TagItemsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "tag_items_tag_id", + Columns: []*schema.Column{TagItemsColumns[0]}, + RefColumns: []*schema.Column{TagsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "tag_items_item_id", + Columns: []*schema.Column{TagItemsColumns[1]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AccountsTable, AssetsTable, AuthenticationsTable, CategoriesTable, + ClustersTable, CollectionsTable, + ItemsTable, NotificationsTable, PostsTable, ReactsTable, @@ -394,17 +578,25 @@ var ( SettingsTable, TagsTable, AccountTagsTable, + ClusterItemsTable, + ClusterAssetsTable, CollectionPostsTable, + ItemAssetsTable, PostAssetsTable, RoleAccountsTable, TagPostsTable, + TagClustersTable, + TagItemsTable, } ) func init() { AssetsTable.ForeignKeys[0].RefTable = AccountsTable AuthenticationsTable.ForeignKeys[0].RefTable = AccountsTable + ClustersTable.ForeignKeys[0].RefTable = AccountsTable + ClustersTable.ForeignKeys[1].RefTable = ClustersTable CollectionsTable.ForeignKeys[0].RefTable = AccountsTable + ItemsTable.ForeignKeys[0].RefTable = AccountsTable PostsTable.ForeignKeys[0].RefTable = AccountsTable PostsTable.ForeignKeys[1].RefTable = CategoriesTable PostsTable.ForeignKeys[2].RefTable = PostsTable @@ -413,12 +605,22 @@ func init() { ReactsTable.ForeignKeys[1].RefTable = PostsTable AccountTagsTable.ForeignKeys[0].RefTable = AccountsTable AccountTagsTable.ForeignKeys[1].RefTable = TagsTable + ClusterItemsTable.ForeignKeys[0].RefTable = ClustersTable + ClusterItemsTable.ForeignKeys[1].RefTable = ItemsTable + ClusterAssetsTable.ForeignKeys[0].RefTable = ClustersTable + ClusterAssetsTable.ForeignKeys[1].RefTable = AssetsTable CollectionPostsTable.ForeignKeys[0].RefTable = CollectionsTable CollectionPostsTable.ForeignKeys[1].RefTable = PostsTable + ItemAssetsTable.ForeignKeys[0].RefTable = ItemsTable + ItemAssetsTable.ForeignKeys[1].RefTable = AssetsTable PostAssetsTable.ForeignKeys[0].RefTable = PostsTable PostAssetsTable.ForeignKeys[1].RefTable = AssetsTable RoleAccountsTable.ForeignKeys[0].RefTable = RolesTable RoleAccountsTable.ForeignKeys[1].RefTable = AccountsTable TagPostsTable.ForeignKeys[0].RefTable = TagsTable TagPostsTable.ForeignKeys[1].RefTable = PostsTable + TagClustersTable.ForeignKeys[0].RefTable = TagsTable + TagClustersTable.ForeignKeys[1].RefTable = ClustersTable + TagItemsTable.ForeignKeys[0].RefTable = TagsTable + TagItemsTable.ForeignKeys[1].RefTable = ItemsTable } diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go index 7309c2589..e35efc578 100644 --- a/internal/ent/mutation.go +++ b/internal/ent/mutation.go @@ -15,7 +15,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" "github.com/Southclaws/storyden/internal/ent/category" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/notification" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" @@ -39,7 +41,9 @@ const ( TypeAsset = "Asset" TypeAuthentication = "Authentication" TypeCategory = "Category" + TypeCluster = "Cluster" TypeCollection = "Collection" + TypeItem = "Item" TypeNotification = "Notification" TypePost = "Post" TypeReact = "React" @@ -80,6 +84,12 @@ type AccountMutation struct { collections map[xid.ID]struct{} removedcollections map[xid.ID]struct{} clearedcollections bool + clusters map[xid.ID]struct{} + removedclusters map[xid.ID]struct{} + clearedclusters bool + items map[xid.ID]struct{} + removeditems map[xid.ID]struct{} + cleareditems bool assets map[string]struct{} removedassets map[string]struct{} clearedassets bool @@ -794,6 +804,114 @@ func (m *AccountMutation) ResetCollections() { m.removedcollections = nil } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by ids. +func (m *AccountMutation) AddClusterIDs(ids ...xid.ID) { + if m.clusters == nil { + m.clusters = make(map[xid.ID]struct{}) + } + for i := range ids { + m.clusters[ids[i]] = struct{}{} + } +} + +// ClearClusters clears the "clusters" edge to the Cluster entity. +func (m *AccountMutation) ClearClusters() { + m.clearedclusters = true +} + +// ClustersCleared reports if the "clusters" edge to the Cluster entity was cleared. +func (m *AccountMutation) ClustersCleared() bool { + return m.clearedclusters +} + +// RemoveClusterIDs removes the "clusters" edge to the Cluster entity by IDs. +func (m *AccountMutation) RemoveClusterIDs(ids ...xid.ID) { + if m.removedclusters == nil { + m.removedclusters = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.clusters, ids[i]) + m.removedclusters[ids[i]] = struct{}{} + } +} + +// RemovedClusters returns the removed IDs of the "clusters" edge to the Cluster entity. +func (m *AccountMutation) RemovedClustersIDs() (ids []xid.ID) { + for id := range m.removedclusters { + ids = append(ids, id) + } + return +} + +// ClustersIDs returns the "clusters" edge IDs in the mutation. +func (m *AccountMutation) ClustersIDs() (ids []xid.ID) { + for id := range m.clusters { + ids = append(ids, id) + } + return +} + +// ResetClusters resets all changes to the "clusters" edge. +func (m *AccountMutation) ResetClusters() { + m.clusters = nil + m.clearedclusters = false + m.removedclusters = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *AccountMutation) AddItemIDs(ids ...xid.ID) { + if m.items == nil { + m.items = make(map[xid.ID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *AccountMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *AccountMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *AccountMutation) RemoveItemIDs(ids ...xid.ID) { + if m.removeditems == nil { + m.removeditems = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *AccountMutation) RemovedItemsIDs() (ids []xid.ID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *AccountMutation) ItemsIDs() (ids []xid.ID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *AccountMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil +} + // AddAssetIDs adds the "assets" edge to the Asset entity by ids. func (m *AccountMutation) AddAssetIDs(ids ...string) { if m.assets == nil { @@ -1098,7 +1216,7 @@ func (m *AccountMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AccountMutation) AddedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 9) if m.posts != nil { edges = append(edges, account.EdgePosts) } @@ -1117,6 +1235,12 @@ func (m *AccountMutation) AddedEdges() []string { if m.collections != nil { edges = append(edges, account.EdgeCollections) } + if m.clusters != nil { + edges = append(edges, account.EdgeClusters) + } + if m.items != nil { + edges = append(edges, account.EdgeItems) + } if m.assets != nil { edges = append(edges, account.EdgeAssets) } @@ -1163,6 +1287,18 @@ func (m *AccountMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case account.EdgeClusters: + ids := make([]ent.Value, 0, len(m.clusters)) + for id := range m.clusters { + ids = append(ids, id) + } + return ids + case account.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { + ids = append(ids, id) + } + return ids case account.EdgeAssets: ids := make([]ent.Value, 0, len(m.assets)) for id := range m.assets { @@ -1175,7 +1311,7 @@ func (m *AccountMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *AccountMutation) RemovedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 9) if m.removedposts != nil { edges = append(edges, account.EdgePosts) } @@ -1194,6 +1330,12 @@ func (m *AccountMutation) RemovedEdges() []string { if m.removedcollections != nil { edges = append(edges, account.EdgeCollections) } + if m.removedclusters != nil { + edges = append(edges, account.EdgeClusters) + } + if m.removeditems != nil { + edges = append(edges, account.EdgeItems) + } if m.removedassets != nil { edges = append(edges, account.EdgeAssets) } @@ -1240,6 +1382,18 @@ func (m *AccountMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case account.EdgeClusters: + ids := make([]ent.Value, 0, len(m.removedclusters)) + for id := range m.removedclusters { + ids = append(ids, id) + } + return ids + case account.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { + ids = append(ids, id) + } + return ids case account.EdgeAssets: ids := make([]ent.Value, 0, len(m.removedassets)) for id := range m.removedassets { @@ -1252,7 +1406,7 @@ func (m *AccountMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AccountMutation) ClearedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 9) if m.clearedposts { edges = append(edges, account.EdgePosts) } @@ -1271,6 +1425,12 @@ func (m *AccountMutation) ClearedEdges() []string { if m.clearedcollections { edges = append(edges, account.EdgeCollections) } + if m.clearedclusters { + edges = append(edges, account.EdgeClusters) + } + if m.cleareditems { + edges = append(edges, account.EdgeItems) + } if m.clearedassets { edges = append(edges, account.EdgeAssets) } @@ -1293,6 +1453,10 @@ func (m *AccountMutation) EdgeCleared(name string) bool { return m.clearedtags case account.EdgeCollections: return m.clearedcollections + case account.EdgeClusters: + return m.clearedclusters + case account.EdgeItems: + return m.cleareditems case account.EdgeAssets: return m.clearedassets } @@ -1329,6 +1493,12 @@ func (m *AccountMutation) ResetEdge(name string) error { case account.EdgeCollections: m.ResetCollections() return nil + case account.EdgeClusters: + m.ResetClusters() + return nil + case account.EdgeItems: + m.ResetItems() + return nil case account.EdgeAssets: m.ResetAssets() return nil @@ -1339,26 +1509,32 @@ func (m *AccountMutation) ResetEdge(name string) error { // AssetMutation represents an operation that mutates the Asset nodes in the graph. type AssetMutation struct { config - op Op - typ string - id *string - created_at *time.Time - updated_at *time.Time - url *string - mimetype *string - width *int - addwidth *int - height *int - addheight *int - clearedFields map[string]struct{} - posts map[xid.ID]struct{} - removedposts map[xid.ID]struct{} - clearedposts bool - owner *xid.ID - clearedowner bool - done bool - oldValue func(context.Context) (*Asset, error) - predicates []predicate.Asset + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + url *string + mimetype *string + width *int + addwidth *int + height *int + addheight *int + clearedFields map[string]struct{} + posts map[xid.ID]struct{} + removedposts map[xid.ID]struct{} + clearedposts bool + clusters map[xid.ID]struct{} + removedclusters map[xid.ID]struct{} + clearedclusters bool + items map[xid.ID]struct{} + removeditems map[xid.ID]struct{} + cleareditems bool + owner *xid.ID + clearedowner bool + done bool + oldValue func(context.Context) (*Asset, error) + predicates []predicate.Asset } var _ ent.Mutation = (*AssetMutation)(nil) @@ -1811,6 +1987,114 @@ func (m *AssetMutation) ResetPosts() { m.removedposts = nil } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by ids. +func (m *AssetMutation) AddClusterIDs(ids ...xid.ID) { + if m.clusters == nil { + m.clusters = make(map[xid.ID]struct{}) + } + for i := range ids { + m.clusters[ids[i]] = struct{}{} + } +} + +// ClearClusters clears the "clusters" edge to the Cluster entity. +func (m *AssetMutation) ClearClusters() { + m.clearedclusters = true +} + +// ClustersCleared reports if the "clusters" edge to the Cluster entity was cleared. +func (m *AssetMutation) ClustersCleared() bool { + return m.clearedclusters +} + +// RemoveClusterIDs removes the "clusters" edge to the Cluster entity by IDs. +func (m *AssetMutation) RemoveClusterIDs(ids ...xid.ID) { + if m.removedclusters == nil { + m.removedclusters = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.clusters, ids[i]) + m.removedclusters[ids[i]] = struct{}{} + } +} + +// RemovedClusters returns the removed IDs of the "clusters" edge to the Cluster entity. +func (m *AssetMutation) RemovedClustersIDs() (ids []xid.ID) { + for id := range m.removedclusters { + ids = append(ids, id) + } + return +} + +// ClustersIDs returns the "clusters" edge IDs in the mutation. +func (m *AssetMutation) ClustersIDs() (ids []xid.ID) { + for id := range m.clusters { + ids = append(ids, id) + } + return +} + +// ResetClusters resets all changes to the "clusters" edge. +func (m *AssetMutation) ResetClusters() { + m.clusters = nil + m.clearedclusters = false + m.removedclusters = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *AssetMutation) AddItemIDs(ids ...xid.ID) { + if m.items == nil { + m.items = make(map[xid.ID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *AssetMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *AssetMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *AssetMutation) RemoveItemIDs(ids ...xid.ID) { + if m.removeditems == nil { + m.removeditems = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *AssetMutation) RemovedItemsIDs() (ids []xid.ID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *AssetMutation) ItemsIDs() (ids []xid.ID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *AssetMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil +} + // SetOwnerID sets the "owner" edge to the Account entity by id. func (m *AssetMutation) SetOwnerID(id xid.ID) { m.owner = &id @@ -2112,10 +2396,16 @@ func (m *AssetMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AssetMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.posts != nil { edges = append(edges, asset.EdgePosts) } + if m.clusters != nil { + edges = append(edges, asset.EdgeClusters) + } + if m.items != nil { + edges = append(edges, asset.EdgeItems) + } if m.owner != nil { edges = append(edges, asset.EdgeOwner) } @@ -2132,6 +2422,18 @@ func (m *AssetMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case asset.EdgeClusters: + ids := make([]ent.Value, 0, len(m.clusters)) + for id := range m.clusters { + ids = append(ids, id) + } + return ids + case asset.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { + ids = append(ids, id) + } + return ids case asset.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} @@ -2142,10 +2444,16 @@ func (m *AssetMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *AssetMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.removedposts != nil { edges = append(edges, asset.EdgePosts) } + if m.removedclusters != nil { + edges = append(edges, asset.EdgeClusters) + } + if m.removeditems != nil { + edges = append(edges, asset.EdgeItems) + } return edges } @@ -2159,16 +2467,34 @@ func (m *AssetMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case asset.EdgeClusters: + ids := make([]ent.Value, 0, len(m.removedclusters)) + for id := range m.removedclusters { + ids = append(ids, id) + } + return ids + case asset.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AssetMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.clearedposts { edges = append(edges, asset.EdgePosts) } + if m.clearedclusters { + edges = append(edges, asset.EdgeClusters) + } + if m.cleareditems { + edges = append(edges, asset.EdgeItems) + } if m.clearedowner { edges = append(edges, asset.EdgeOwner) } @@ -2181,6 +2507,10 @@ func (m *AssetMutation) EdgeCleared(name string) bool { switch name { case asset.EdgePosts: return m.clearedposts + case asset.EdgeClusters: + return m.clearedclusters + case asset.EdgeItems: + return m.cleareditems case asset.EdgeOwner: return m.clearedowner } @@ -2205,6 +2535,12 @@ func (m *AssetMutation) ResetEdge(name string) error { case asset.EdgePosts: m.ResetPosts() return nil + case asset.EdgeClusters: + m.ResetClusters() + return nil + case asset.EdgeItems: + m.ResetItems() + return nil case asset.EdgeOwner: m.ResetOwner() return nil @@ -3764,38 +4100,51 @@ func (m *CategoryMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Category edge %s", name) } -// CollectionMutation represents an operation that mutates the Collection nodes in the graph. -type CollectionMutation struct { +// ClusterMutation represents an operation that mutates the Cluster nodes in the graph. +type ClusterMutation struct { config - op Op - typ string - id *xid.ID - created_at *time.Time - updated_at *time.Time - name *string - description *string - clearedFields map[string]struct{} - owner *xid.ID - clearedowner bool - posts map[xid.ID]struct{} - removedposts map[xid.ID]struct{} - clearedposts bool - done bool - oldValue func(context.Context) (*Collection, error) - predicates []predicate.Collection + op Op + typ string + id *xid.ID + created_at *time.Time + updated_at *time.Time + name *string + slug *string + image_url *string + description *string + clearedFields map[string]struct{} + owner *xid.ID + clearedowner bool + parent *xid.ID + clearedparent bool + clusters map[xid.ID]struct{} + removedclusters map[xid.ID]struct{} + clearedclusters bool + items map[xid.ID]struct{} + removeditems map[xid.ID]struct{} + cleareditems bool + assets map[string]struct{} + removedassets map[string]struct{} + clearedassets bool + tags map[xid.ID]struct{} + removedtags map[xid.ID]struct{} + clearedtags bool + done bool + oldValue func(context.Context) (*Cluster, error) + predicates []predicate.Cluster } -var _ ent.Mutation = (*CollectionMutation)(nil) +var _ ent.Mutation = (*ClusterMutation)(nil) -// collectionOption allows management of the mutation configuration using functional options. -type collectionOption func(*CollectionMutation) +// clusterOption allows management of the mutation configuration using functional options. +type clusterOption func(*ClusterMutation) -// newCollectionMutation creates new mutation for the Collection entity. -func newCollectionMutation(c config, op Op, opts ...collectionOption) *CollectionMutation { - m := &CollectionMutation{ +// newClusterMutation creates new mutation for the Cluster entity. +func newClusterMutation(c config, op Op, opts ...clusterOption) *ClusterMutation { + m := &ClusterMutation{ config: c, op: op, - typ: TypeCollection, + typ: TypeCluster, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -3804,20 +4153,20 @@ func newCollectionMutation(c config, op Op, opts ...collectionOption) *Collectio return m } -// withCollectionID sets the ID field of the mutation. -func withCollectionID(id xid.ID) collectionOption { - return func(m *CollectionMutation) { +// withClusterID sets the ID field of the mutation. +func withClusterID(id xid.ID) clusterOption { + return func(m *ClusterMutation) { var ( err error once sync.Once - value *Collection + value *Cluster ) - m.oldValue = func(ctx context.Context) (*Collection, error) { + m.oldValue = func(ctx context.Context) (*Cluster, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Collection.Get(ctx, id) + value, err = m.Client().Cluster.Get(ctx, id) } }) return value, err @@ -3826,10 +4175,10 @@ func withCollectionID(id xid.ID) collectionOption { } } -// withCollection sets the old Collection of the mutation. -func withCollection(node *Collection) collectionOption { - return func(m *CollectionMutation) { - m.oldValue = func(context.Context) (*Collection, error) { +// withCluster sets the old Cluster of the mutation. +func withCluster(node *Cluster) clusterOption { + return func(m *ClusterMutation) { + m.oldValue = func(context.Context) (*Cluster, error) { return node, nil } m.id = &node.ID @@ -3838,7 +4187,7 @@ func withCollection(node *Collection) collectionOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m CollectionMutation) Client() *Client { +func (m ClusterMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -3846,7 +4195,7 @@ func (m CollectionMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m CollectionMutation) Tx() (*Tx, error) { +func (m ClusterMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -3856,14 +4205,14 @@ func (m CollectionMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Collection entities. -func (m *CollectionMutation) SetID(id xid.ID) { +// operation is only accepted on creation of Cluster entities. +func (m *ClusterMutation) SetID(id xid.ID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *CollectionMutation) ID() (id xid.ID, exists bool) { +func (m *ClusterMutation) ID() (id xid.ID, exists bool) { if m.id == nil { return } @@ -3874,7 +4223,7 @@ func (m *CollectionMutation) ID() (id xid.ID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *CollectionMutation) IDs(ctx context.Context) ([]xid.ID, error) { +func (m *ClusterMutation) IDs(ctx context.Context) ([]xid.ID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -3883,19 +4232,19 @@ func (m *CollectionMutation) IDs(ctx context.Context) ([]xid.ID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Collection.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Cluster.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetCreatedAt sets the "created_at" field. -func (m *CollectionMutation) SetCreatedAt(t time.Time) { +func (m *ClusterMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *CollectionMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ClusterMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -3903,10 +4252,10 @@ func (m *CollectionMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Collection entity. -// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CollectionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ClusterMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -3921,17 +4270,17 @@ func (m *CollectionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *CollectionMutation) ResetCreatedAt() { +func (m *ClusterMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. -func (m *CollectionMutation) SetUpdatedAt(t time.Time) { +func (m *ClusterMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *CollectionMutation) UpdatedAt() (r time.Time, exists bool) { +func (m *ClusterMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return @@ -3939,10 +4288,10 @@ func (m *CollectionMutation) UpdatedAt() (r time.Time, exists bool) { return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the Collection entity. -// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CollectionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ClusterMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } @@ -3957,17 +4306,17 @@ func (m *CollectionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err } // ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *CollectionMutation) ResetUpdatedAt() { +func (m *ClusterMutation) ResetUpdatedAt() { m.updated_at = nil } // SetName sets the "name" field. -func (m *CollectionMutation) SetName(s string) { +func (m *ClusterMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *CollectionMutation) Name() (r string, exists bool) { +func (m *ClusterMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -3975,10 +4324,10 @@ func (m *CollectionMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the Collection entity. -// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CollectionMutation) OldName(ctx context.Context) (v string, err error) { +func (m *ClusterMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } @@ -3993,63 +4342,2034 @@ func (m *CollectionMutation) OldName(ctx context.Context) (v string, err error) } // ResetName resets all changes to the "name" field. -func (m *CollectionMutation) ResetName() { +func (m *ClusterMutation) ResetName() { m.name = nil } -// SetDescription sets the "description" field. -func (m *CollectionMutation) SetDescription(s string) { - m.description = &s +// SetSlug sets the "slug" field. +func (m *ClusterMutation) SetSlug(s string) { + m.slug = &s } -// Description returns the value of the "description" field in the mutation. -func (m *CollectionMutation) Description() (r string, exists bool) { - v := m.description +// Slug returns the value of the "slug" field in the mutation. +func (m *ClusterMutation) Slug() (r string, exists bool) { + v := m.slug if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Collection entity. -// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// OldSlug returns the old "slug" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CollectionMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *ClusterMutation) OldSlug(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldSlug is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldSlug requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldSlug: %w", err) } - return oldValue.Description, nil + return oldValue.Slug, nil +} + +// ResetSlug resets all changes to the "slug" field. +func (m *ClusterMutation) ResetSlug() { + m.slug = nil +} + +// SetImageURL sets the "image_url" field. +func (m *ClusterMutation) SetImageURL(s string) { + m.image_url = &s +} + +// ImageURL returns the value of the "image_url" field in the mutation. +func (m *ClusterMutation) ImageURL() (r string, exists bool) { + v := m.image_url + if v == nil { + return + } + return *v, true +} + +// OldImageURL returns the old "image_url" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ClusterMutation) OldImageURL(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImageURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImageURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImageURL: %w", err) + } + return oldValue.ImageURL, nil +} + +// ClearImageURL clears the value of the "image_url" field. +func (m *ClusterMutation) ClearImageURL() { + m.image_url = nil + m.clearedFields[cluster.FieldImageURL] = struct{}{} +} + +// ImageURLCleared returns if the "image_url" field was cleared in this mutation. +func (m *ClusterMutation) ImageURLCleared() bool { + _, ok := m.clearedFields[cluster.FieldImageURL] + return ok +} + +// ResetImageURL resets all changes to the "image_url" field. +func (m *ClusterMutation) ResetImageURL() { + m.image_url = nil + delete(m.clearedFields, cluster.FieldImageURL) +} + +// SetDescription sets the "description" field. +func (m *ClusterMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ClusterMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ClusterMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *ClusterMutation) ResetDescription() { + m.description = nil +} + +// SetParentClusterID sets the "parent_cluster_id" field. +func (m *ClusterMutation) SetParentClusterID(x xid.ID) { + m.parent = &x +} + +// ParentClusterID returns the value of the "parent_cluster_id" field in the mutation. +func (m *ClusterMutation) ParentClusterID() (r xid.ID, exists bool) { + v := m.parent + if v == nil { + return + } + return *v, true +} + +// OldParentClusterID returns the old "parent_cluster_id" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ClusterMutation) OldParentClusterID(ctx context.Context) (v xid.ID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentClusterID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentClusterID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentClusterID: %w", err) + } + return oldValue.ParentClusterID, nil +} + +// ClearParentClusterID clears the value of the "parent_cluster_id" field. +func (m *ClusterMutation) ClearParentClusterID() { + m.parent = nil + m.clearedFields[cluster.FieldParentClusterID] = struct{}{} +} + +// ParentClusterIDCleared returns if the "parent_cluster_id" field was cleared in this mutation. +func (m *ClusterMutation) ParentClusterIDCleared() bool { + _, ok := m.clearedFields[cluster.FieldParentClusterID] + return ok +} + +// ResetParentClusterID resets all changes to the "parent_cluster_id" field. +func (m *ClusterMutation) ResetParentClusterID() { + m.parent = nil + delete(m.clearedFields, cluster.FieldParentClusterID) +} + +// SetAccountID sets the "account_id" field. +func (m *ClusterMutation) SetAccountID(x xid.ID) { + m.owner = &x +} + +// AccountID returns the value of the "account_id" field in the mutation. +func (m *ClusterMutation) AccountID() (r xid.ID, exists bool) { + v := m.owner + if v == nil { + return + } + return *v, true +} + +// OldAccountID returns the old "account_id" field's value of the Cluster entity. +// If the Cluster object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ClusterMutation) OldAccountID(ctx context.Context) (v xid.ID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccountID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccountID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccountID: %w", err) + } + return oldValue.AccountID, nil +} + +// ResetAccountID resets all changes to the "account_id" field. +func (m *ClusterMutation) ResetAccountID() { + m.owner = nil +} + +// SetOwnerID sets the "owner" edge to the Account entity by id. +func (m *ClusterMutation) SetOwnerID(id xid.ID) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (m *ClusterMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the Account entity was cleared. +func (m *ClusterMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *ClusterMutation) OwnerID() (id xid.ID, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *ClusterMutation) OwnerIDs() (ids []xid.ID) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOwner resets all changes to the "owner" edge. +func (m *ClusterMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false +} + +// SetParentID sets the "parent" edge to the Cluster entity by id. +func (m *ClusterMutation) SetParentID(id xid.ID) { + m.parent = &id +} + +// ClearParent clears the "parent" edge to the Cluster entity. +func (m *ClusterMutation) ClearParent() { + m.clearedparent = true +} + +// ParentCleared reports if the "parent" edge to the Cluster entity was cleared. +func (m *ClusterMutation) ParentCleared() bool { + return m.ParentClusterIDCleared() || m.clearedparent +} + +// ParentID returns the "parent" edge ID in the mutation. +func (m *ClusterMutation) ParentID() (id xid.ID, exists bool) { + if m.parent != nil { + return *m.parent, true + } + return +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ClusterMutation) ParentIDs() (ids []xid.ID) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetParent resets all changes to the "parent" edge. +func (m *ClusterMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddClusterIDs adds the "clusters" edge to the Cluster entity by ids. +func (m *ClusterMutation) AddClusterIDs(ids ...xid.ID) { + if m.clusters == nil { + m.clusters = make(map[xid.ID]struct{}) + } + for i := range ids { + m.clusters[ids[i]] = struct{}{} + } +} + +// ClearClusters clears the "clusters" edge to the Cluster entity. +func (m *ClusterMutation) ClearClusters() { + m.clearedclusters = true +} + +// ClustersCleared reports if the "clusters" edge to the Cluster entity was cleared. +func (m *ClusterMutation) ClustersCleared() bool { + return m.clearedclusters +} + +// RemoveClusterIDs removes the "clusters" edge to the Cluster entity by IDs. +func (m *ClusterMutation) RemoveClusterIDs(ids ...xid.ID) { + if m.removedclusters == nil { + m.removedclusters = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.clusters, ids[i]) + m.removedclusters[ids[i]] = struct{}{} + } +} + +// RemovedClusters returns the removed IDs of the "clusters" edge to the Cluster entity. +func (m *ClusterMutation) RemovedClustersIDs() (ids []xid.ID) { + for id := range m.removedclusters { + ids = append(ids, id) + } + return +} + +// ClustersIDs returns the "clusters" edge IDs in the mutation. +func (m *ClusterMutation) ClustersIDs() (ids []xid.ID) { + for id := range m.clusters { + ids = append(ids, id) + } + return +} + +// ResetClusters resets all changes to the "clusters" edge. +func (m *ClusterMutation) ResetClusters() { + m.clusters = nil + m.clearedclusters = false + m.removedclusters = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *ClusterMutation) AddItemIDs(ids ...xid.ID) { + if m.items == nil { + m.items = make(map[xid.ID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *ClusterMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *ClusterMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *ClusterMutation) RemoveItemIDs(ids ...xid.ID) { + if m.removeditems == nil { + m.removeditems = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *ClusterMutation) RemovedItemsIDs() (ids []xid.ID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *ClusterMutation) ItemsIDs() (ids []xid.ID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *ClusterMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by ids. +func (m *ClusterMutation) AddAssetIDs(ids ...string) { + if m.assets == nil { + m.assets = make(map[string]struct{}) + } + for i := range ids { + m.assets[ids[i]] = struct{}{} + } +} + +// ClearAssets clears the "assets" edge to the Asset entity. +func (m *ClusterMutation) ClearAssets() { + m.clearedassets = true +} + +// AssetsCleared reports if the "assets" edge to the Asset entity was cleared. +func (m *ClusterMutation) AssetsCleared() bool { + return m.clearedassets +} + +// RemoveAssetIDs removes the "assets" edge to the Asset entity by IDs. +func (m *ClusterMutation) RemoveAssetIDs(ids ...string) { + if m.removedassets == nil { + m.removedassets = make(map[string]struct{}) + } + for i := range ids { + delete(m.assets, ids[i]) + m.removedassets[ids[i]] = struct{}{} + } +} + +// RemovedAssets returns the removed IDs of the "assets" edge to the Asset entity. +func (m *ClusterMutation) RemovedAssetsIDs() (ids []string) { + for id := range m.removedassets { + ids = append(ids, id) + } + return +} + +// AssetsIDs returns the "assets" edge IDs in the mutation. +func (m *ClusterMutation) AssetsIDs() (ids []string) { + for id := range m.assets { + ids = append(ids, id) + } + return +} + +// ResetAssets resets all changes to the "assets" edge. +func (m *ClusterMutation) ResetAssets() { + m.assets = nil + m.clearedassets = false + m.removedassets = nil +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *ClusterMutation) AddTagIDs(ids ...xid.ID) { + if m.tags == nil { + m.tags = make(map[xid.ID]struct{}) + } + for i := range ids { + m.tags[ids[i]] = struct{}{} + } +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *ClusterMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *ClusterMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *ClusterMutation) RemoveTagIDs(ids ...xid.ID) { + if m.removedtags == nil { + m.removedtags = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} + } +} + +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *ClusterMutation) RemovedTagsIDs() (ids []xid.ID) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *ClusterMutation) TagsIDs() (ids []xid.ID) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *ClusterMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// Where appends a list predicates to the ClusterMutation builder. +func (m *ClusterMutation) Where(ps ...predicate.Cluster) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ClusterMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ClusterMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Cluster, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ClusterMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ClusterMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Cluster). +func (m *ClusterMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ClusterMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.created_at != nil { + fields = append(fields, cluster.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, cluster.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, cluster.FieldName) + } + if m.slug != nil { + fields = append(fields, cluster.FieldSlug) + } + if m.image_url != nil { + fields = append(fields, cluster.FieldImageURL) + } + if m.description != nil { + fields = append(fields, cluster.FieldDescription) + } + if m.parent != nil { + fields = append(fields, cluster.FieldParentClusterID) + } + if m.owner != nil { + fields = append(fields, cluster.FieldAccountID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ClusterMutation) Field(name string) (ent.Value, bool) { + switch name { + case cluster.FieldCreatedAt: + return m.CreatedAt() + case cluster.FieldUpdatedAt: + return m.UpdatedAt() + case cluster.FieldName: + return m.Name() + case cluster.FieldSlug: + return m.Slug() + case cluster.FieldImageURL: + return m.ImageURL() + case cluster.FieldDescription: + return m.Description() + case cluster.FieldParentClusterID: + return m.ParentClusterID() + case cluster.FieldAccountID: + return m.AccountID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ClusterMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case cluster.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case cluster.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case cluster.FieldName: + return m.OldName(ctx) + case cluster.FieldSlug: + return m.OldSlug(ctx) + case cluster.FieldImageURL: + return m.OldImageURL(ctx) + case cluster.FieldDescription: + return m.OldDescription(ctx) + case cluster.FieldParentClusterID: + return m.OldParentClusterID(ctx) + case cluster.FieldAccountID: + return m.OldAccountID(ctx) + } + return nil, fmt.Errorf("unknown Cluster field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ClusterMutation) SetField(name string, value ent.Value) error { + switch name { + case cluster.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case cluster.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case cluster.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case cluster.FieldSlug: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSlug(v) + return nil + case cluster.FieldImageURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImageURL(v) + return nil + case cluster.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case cluster.FieldParentClusterID: + v, ok := value.(xid.ID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentClusterID(v) + return nil + case cluster.FieldAccountID: + v, ok := value.(xid.ID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccountID(v) + return nil + } + return fmt.Errorf("unknown Cluster field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ClusterMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ClusterMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ClusterMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Cluster numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ClusterMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(cluster.FieldImageURL) { + fields = append(fields, cluster.FieldImageURL) + } + if m.FieldCleared(cluster.FieldParentClusterID) { + fields = append(fields, cluster.FieldParentClusterID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ClusterMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ClusterMutation) ClearField(name string) error { + switch name { + case cluster.FieldImageURL: + m.ClearImageURL() + return nil + case cluster.FieldParentClusterID: + m.ClearParentClusterID() + return nil + } + return fmt.Errorf("unknown Cluster nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ClusterMutation) ResetField(name string) error { + switch name { + case cluster.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case cluster.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case cluster.FieldName: + m.ResetName() + return nil + case cluster.FieldSlug: + m.ResetSlug() + return nil + case cluster.FieldImageURL: + m.ResetImageURL() + return nil + case cluster.FieldDescription: + m.ResetDescription() + return nil + case cluster.FieldParentClusterID: + m.ResetParentClusterID() + return nil + case cluster.FieldAccountID: + m.ResetAccountID() + return nil + } + return fmt.Errorf("unknown Cluster field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ClusterMutation) AddedEdges() []string { + edges := make([]string, 0, 6) + if m.owner != nil { + edges = append(edges, cluster.EdgeOwner) + } + if m.parent != nil { + edges = append(edges, cluster.EdgeParent) + } + if m.clusters != nil { + edges = append(edges, cluster.EdgeClusters) + } + if m.items != nil { + edges = append(edges, cluster.EdgeItems) + } + if m.assets != nil { + edges = append(edges, cluster.EdgeAssets) + } + if m.tags != nil { + edges = append(edges, cluster.EdgeTags) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ClusterMutation) AddedIDs(name string) []ent.Value { + switch name { + case cluster.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } + case cluster.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case cluster.EdgeClusters: + ids := make([]ent.Value, 0, len(m.clusters)) + for id := range m.clusters { + ids = append(ids, id) + } + return ids + case cluster.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { + ids = append(ids, id) + } + return ids + case cluster.EdgeAssets: + ids := make([]ent.Value, 0, len(m.assets)) + for id := range m.assets { + ids = append(ids, id) + } + return ids + case cluster.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ClusterMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) + if m.removedclusters != nil { + edges = append(edges, cluster.EdgeClusters) + } + if m.removeditems != nil { + edges = append(edges, cluster.EdgeItems) + } + if m.removedassets != nil { + edges = append(edges, cluster.EdgeAssets) + } + if m.removedtags != nil { + edges = append(edges, cluster.EdgeTags) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ClusterMutation) RemovedIDs(name string) []ent.Value { + switch name { + case cluster.EdgeClusters: + ids := make([]ent.Value, 0, len(m.removedclusters)) + for id := range m.removedclusters { + ids = append(ids, id) + } + return ids + case cluster.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { + ids = append(ids, id) + } + return ids + case cluster.EdgeAssets: + ids := make([]ent.Value, 0, len(m.removedassets)) + for id := range m.removedassets { + ids = append(ids, id) + } + return ids + case cluster.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ClusterMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) + if m.clearedowner { + edges = append(edges, cluster.EdgeOwner) + } + if m.clearedparent { + edges = append(edges, cluster.EdgeParent) + } + if m.clearedclusters { + edges = append(edges, cluster.EdgeClusters) + } + if m.cleareditems { + edges = append(edges, cluster.EdgeItems) + } + if m.clearedassets { + edges = append(edges, cluster.EdgeAssets) + } + if m.clearedtags { + edges = append(edges, cluster.EdgeTags) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ClusterMutation) EdgeCleared(name string) bool { + switch name { + case cluster.EdgeOwner: + return m.clearedowner + case cluster.EdgeParent: + return m.clearedparent + case cluster.EdgeClusters: + return m.clearedclusters + case cluster.EdgeItems: + return m.cleareditems + case cluster.EdgeAssets: + return m.clearedassets + case cluster.EdgeTags: + return m.clearedtags + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ClusterMutation) ClearEdge(name string) error { + switch name { + case cluster.EdgeOwner: + m.ClearOwner() + return nil + case cluster.EdgeParent: + m.ClearParent() + return nil + } + return fmt.Errorf("unknown Cluster unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ClusterMutation) ResetEdge(name string) error { + switch name { + case cluster.EdgeOwner: + m.ResetOwner() + return nil + case cluster.EdgeParent: + m.ResetParent() + return nil + case cluster.EdgeClusters: + m.ResetClusters() + return nil + case cluster.EdgeItems: + m.ResetItems() + return nil + case cluster.EdgeAssets: + m.ResetAssets() + return nil + case cluster.EdgeTags: + m.ResetTags() + return nil + } + return fmt.Errorf("unknown Cluster edge %s", name) +} + +// CollectionMutation represents an operation that mutates the Collection nodes in the graph. +type CollectionMutation struct { + config + op Op + typ string + id *xid.ID + created_at *time.Time + updated_at *time.Time + name *string + description *string + clearedFields map[string]struct{} + owner *xid.ID + clearedowner bool + posts map[xid.ID]struct{} + removedposts map[xid.ID]struct{} + clearedposts bool + done bool + oldValue func(context.Context) (*Collection, error) + predicates []predicate.Collection +} + +var _ ent.Mutation = (*CollectionMutation)(nil) + +// collectionOption allows management of the mutation configuration using functional options. +type collectionOption func(*CollectionMutation) + +// newCollectionMutation creates new mutation for the Collection entity. +func newCollectionMutation(c config, op Op, opts ...collectionOption) *CollectionMutation { + m := &CollectionMutation{ + config: c, + op: op, + typ: TypeCollection, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withCollectionID sets the ID field of the mutation. +func withCollectionID(id xid.ID) collectionOption { + return func(m *CollectionMutation) { + var ( + err error + once sync.Once + value *Collection + ) + m.oldValue = func(ctx context.Context) (*Collection, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Collection.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withCollection sets the old Collection of the mutation. +func withCollection(node *Collection) collectionOption { + return func(m *CollectionMutation) { + m.oldValue = func(context.Context) (*Collection, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m CollectionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m CollectionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Collection entities. +func (m *CollectionMutation) SetID(id xid.ID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *CollectionMutation) ID() (id xid.ID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *CollectionMutation) IDs(ctx context.Context) ([]xid.ID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []xid.ID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Collection.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *CollectionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *CollectionMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Collection entity. +// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CollectionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *CollectionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *CollectionMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *CollectionMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Collection entity. +// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CollectionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *CollectionMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *CollectionMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *CollectionMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Collection entity. +// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CollectionMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *CollectionMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *CollectionMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *CollectionMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Collection entity. +// If the Collection object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CollectionMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *CollectionMutation) ResetDescription() { + m.description = nil +} + +// SetOwnerID sets the "owner" edge to the Account entity by id. +func (m *CollectionMutation) SetOwnerID(id xid.ID) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the Account entity. +func (m *CollectionMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the Account entity was cleared. +func (m *CollectionMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *CollectionMutation) OwnerID() (id xid.ID, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *CollectionMutation) OwnerIDs() (ids []xid.ID) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOwner resets all changes to the "owner" edge. +func (m *CollectionMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false +} + +// AddPostIDs adds the "posts" edge to the Post entity by ids. +func (m *CollectionMutation) AddPostIDs(ids ...xid.ID) { + if m.posts == nil { + m.posts = make(map[xid.ID]struct{}) + } + for i := range ids { + m.posts[ids[i]] = struct{}{} + } +} + +// ClearPosts clears the "posts" edge to the Post entity. +func (m *CollectionMutation) ClearPosts() { + m.clearedposts = true +} + +// PostsCleared reports if the "posts" edge to the Post entity was cleared. +func (m *CollectionMutation) PostsCleared() bool { + return m.clearedposts +} + +// RemovePostIDs removes the "posts" edge to the Post entity by IDs. +func (m *CollectionMutation) RemovePostIDs(ids ...xid.ID) { + if m.removedposts == nil { + m.removedposts = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.posts, ids[i]) + m.removedposts[ids[i]] = struct{}{} + } +} + +// RemovedPosts returns the removed IDs of the "posts" edge to the Post entity. +func (m *CollectionMutation) RemovedPostsIDs() (ids []xid.ID) { + for id := range m.removedposts { + ids = append(ids, id) + } + return +} + +// PostsIDs returns the "posts" edge IDs in the mutation. +func (m *CollectionMutation) PostsIDs() (ids []xid.ID) { + for id := range m.posts { + ids = append(ids, id) + } + return +} + +// ResetPosts resets all changes to the "posts" edge. +func (m *CollectionMutation) ResetPosts() { + m.posts = nil + m.clearedposts = false + m.removedposts = nil +} + +// Where appends a list predicates to the CollectionMutation builder. +func (m *CollectionMutation) Where(ps ...predicate.Collection) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the CollectionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *CollectionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Collection, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *CollectionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *CollectionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Collection). +func (m *CollectionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *CollectionMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.created_at != nil { + fields = append(fields, collection.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, collection.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, collection.FieldName) + } + if m.description != nil { + fields = append(fields, collection.FieldDescription) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *CollectionMutation) Field(name string) (ent.Value, bool) { + switch name { + case collection.FieldCreatedAt: + return m.CreatedAt() + case collection.FieldUpdatedAt: + return m.UpdatedAt() + case collection.FieldName: + return m.Name() + case collection.FieldDescription: + return m.Description() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *CollectionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case collection.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case collection.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case collection.FieldName: + return m.OldName(ctx) + case collection.FieldDescription: + return m.OldDescription(ctx) + } + return nil, fmt.Errorf("unknown Collection field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *CollectionMutation) SetField(name string, value ent.Value) error { + switch name { + case collection.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case collection.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case collection.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case collection.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + } + return fmt.Errorf("unknown Collection field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *CollectionMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *CollectionMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *CollectionMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Collection numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *CollectionMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *CollectionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *CollectionMutation) ClearField(name string) error { + return fmt.Errorf("unknown Collection nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *CollectionMutation) ResetField(name string) error { + switch name { + case collection.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case collection.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case collection.FieldName: + m.ResetName() + return nil + case collection.FieldDescription: + m.ResetDescription() + return nil + } + return fmt.Errorf("unknown Collection field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *CollectionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.owner != nil { + edges = append(edges, collection.EdgeOwner) + } + if m.posts != nil { + edges = append(edges, collection.EdgePosts) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *CollectionMutation) AddedIDs(name string) []ent.Value { + switch name { + case collection.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } + case collection.EdgePosts: + ids := make([]ent.Value, 0, len(m.posts)) + for id := range m.posts { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *CollectionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedposts != nil { + edges = append(edges, collection.EdgePosts) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *CollectionMutation) RemovedIDs(name string) []ent.Value { + switch name { + case collection.EdgePosts: + ids := make([]ent.Value, 0, len(m.removedposts)) + for id := range m.removedposts { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *CollectionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedowner { + edges = append(edges, collection.EdgeOwner) + } + if m.clearedposts { + edges = append(edges, collection.EdgePosts) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *CollectionMutation) EdgeCleared(name string) bool { + switch name { + case collection.EdgeOwner: + return m.clearedowner + case collection.EdgePosts: + return m.clearedposts + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *CollectionMutation) ClearEdge(name string) error { + switch name { + case collection.EdgeOwner: + m.ClearOwner() + return nil + } + return fmt.Errorf("unknown Collection unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *CollectionMutation) ResetEdge(name string) error { + switch name { + case collection.EdgeOwner: + m.ResetOwner() + return nil + case collection.EdgePosts: + m.ResetPosts() + return nil + } + return fmt.Errorf("unknown Collection edge %s", name) +} + +// ItemMutation represents an operation that mutates the Item nodes in the graph. +type ItemMutation struct { + config + op Op + typ string + id *xid.ID + created_at *time.Time + updated_at *time.Time + name *string + slug *string + image_url *string + description *string + clearedFields map[string]struct{} + owner *xid.ID + clearedowner bool + clusters map[xid.ID]struct{} + removedclusters map[xid.ID]struct{} + clearedclusters bool + assets map[string]struct{} + removedassets map[string]struct{} + clearedassets bool + tags map[xid.ID]struct{} + removedtags map[xid.ID]struct{} + clearedtags bool + done bool + oldValue func(context.Context) (*Item, error) + predicates []predicate.Item +} + +var _ ent.Mutation = (*ItemMutation)(nil) + +// itemOption allows management of the mutation configuration using functional options. +type itemOption func(*ItemMutation) + +// newItemMutation creates new mutation for the Item entity. +func newItemMutation(c config, op Op, opts ...itemOption) *ItemMutation { + m := &ItemMutation{ + config: c, + op: op, + typ: TypeItem, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withItemID sets the ID field of the mutation. +func withItemID(id xid.ID) itemOption { + return func(m *ItemMutation) { + var ( + err error + once sync.Once + value *Item + ) + m.oldValue = func(ctx context.Context) (*Item, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Item.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withItem sets the old Item of the mutation. +func withItem(node *Item) itemOption { + return func(m *ItemMutation) { + m.oldValue = func(context.Context) (*Item, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ItemMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ItemMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Item entities. +func (m *ItemMutation) SetID(id xid.ID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ItemMutation) ID() (id xid.ID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ItemMutation) IDs(ctx context.Context) ([]xid.ID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []xid.ID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Item.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ItemMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ItemMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ItemMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ItemMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ItemMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ItemMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *ItemMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ItemMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ItemMutation) ResetName() { + m.name = nil +} + +// SetSlug sets the "slug" field. +func (m *ItemMutation) SetSlug(s string) { + m.slug = &s +} + +// Slug returns the value of the "slug" field in the mutation. +func (m *ItemMutation) Slug() (r string, exists bool) { + v := m.slug + if v == nil { + return + } + return *v, true +} + +// OldSlug returns the old "slug" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSlug(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSlug is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSlug requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSlug: %w", err) + } + return oldValue.Slug, nil +} + +// ResetSlug resets all changes to the "slug" field. +func (m *ItemMutation) ResetSlug() { + m.slug = nil +} + +// SetImageURL sets the "image_url" field. +func (m *ItemMutation) SetImageURL(s string) { + m.image_url = &s +} + +// ImageURL returns the value of the "image_url" field in the mutation. +func (m *ItemMutation) ImageURL() (r string, exists bool) { + v := m.image_url + if v == nil { + return + } + return *v, true +} + +// OldImageURL returns the old "image_url" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldImageURL(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImageURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImageURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImageURL: %w", err) + } + return oldValue.ImageURL, nil +} + +// ClearImageURL clears the value of the "image_url" field. +func (m *ItemMutation) ClearImageURL() { + m.image_url = nil + m.clearedFields[item.FieldImageURL] = struct{}{} +} + +// ImageURLCleared returns if the "image_url" field was cleared in this mutation. +func (m *ItemMutation) ImageURLCleared() bool { + _, ok := m.clearedFields[item.FieldImageURL] + return ok +} + +// ResetImageURL resets all changes to the "image_url" field. +func (m *ItemMutation) ResetImageURL() { + m.image_url = nil + delete(m.clearedFields, item.FieldImageURL) +} + +// SetDescription sets the "description" field. +func (m *ItemMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ItemMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil } // ResetDescription resets all changes to the "description" field. -func (m *CollectionMutation) ResetDescription() { +func (m *ItemMutation) ResetDescription() { m.description = nil } +// SetAccountID sets the "account_id" field. +func (m *ItemMutation) SetAccountID(x xid.ID) { + m.owner = &x +} + +// AccountID returns the value of the "account_id" field in the mutation. +func (m *ItemMutation) AccountID() (r xid.ID, exists bool) { + v := m.owner + if v == nil { + return + } + return *v, true +} + +// OldAccountID returns the old "account_id" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldAccountID(ctx context.Context) (v xid.ID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccountID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccountID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccountID: %w", err) + } + return oldValue.AccountID, nil +} + +// ResetAccountID resets all changes to the "account_id" field. +func (m *ItemMutation) ResetAccountID() { + m.owner = nil +} + // SetOwnerID sets the "owner" edge to the Account entity by id. -func (m *CollectionMutation) SetOwnerID(id xid.ID) { +func (m *ItemMutation) SetOwnerID(id xid.ID) { m.owner = &id } // ClearOwner clears the "owner" edge to the Account entity. -func (m *CollectionMutation) ClearOwner() { +func (m *ItemMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Account entity was cleared. -func (m *CollectionMutation) OwnerCleared() bool { +func (m *ItemMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *CollectionMutation) OwnerID() (id xid.ID, exists bool) { +func (m *ItemMutation) OwnerID() (id xid.ID, exists bool) { if m.owner != nil { return *m.owner, true } @@ -4059,7 +6379,7 @@ func (m *CollectionMutation) OwnerID() (id xid.ID, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *CollectionMutation) OwnerIDs() (ids []xid.ID) { +func (m *ItemMutation) OwnerIDs() (ids []xid.ID) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -4067,74 +6387,182 @@ func (m *CollectionMutation) OwnerIDs() (ids []xid.ID) { } // ResetOwner resets all changes to the "owner" edge. -func (m *CollectionMutation) ResetOwner() { +func (m *ItemMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// AddPostIDs adds the "posts" edge to the Post entity by ids. -func (m *CollectionMutation) AddPostIDs(ids ...xid.ID) { - if m.posts == nil { - m.posts = make(map[xid.ID]struct{}) +// AddClusterIDs adds the "clusters" edge to the Cluster entity by ids. +func (m *ItemMutation) AddClusterIDs(ids ...xid.ID) { + if m.clusters == nil { + m.clusters = make(map[xid.ID]struct{}) } for i := range ids { - m.posts[ids[i]] = struct{}{} + m.clusters[ids[i]] = struct{}{} } } -// ClearPosts clears the "posts" edge to the Post entity. -func (m *CollectionMutation) ClearPosts() { - m.clearedposts = true +// ClearClusters clears the "clusters" edge to the Cluster entity. +func (m *ItemMutation) ClearClusters() { + m.clearedclusters = true } -// PostsCleared reports if the "posts" edge to the Post entity was cleared. -func (m *CollectionMutation) PostsCleared() bool { - return m.clearedposts +// ClustersCleared reports if the "clusters" edge to the Cluster entity was cleared. +func (m *ItemMutation) ClustersCleared() bool { + return m.clearedclusters } -// RemovePostIDs removes the "posts" edge to the Post entity by IDs. -func (m *CollectionMutation) RemovePostIDs(ids ...xid.ID) { - if m.removedposts == nil { - m.removedposts = make(map[xid.ID]struct{}) +// RemoveClusterIDs removes the "clusters" edge to the Cluster entity by IDs. +func (m *ItemMutation) RemoveClusterIDs(ids ...xid.ID) { + if m.removedclusters == nil { + m.removedclusters = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.clusters, ids[i]) + m.removedclusters[ids[i]] = struct{}{} + } +} + +// RemovedClusters returns the removed IDs of the "clusters" edge to the Cluster entity. +func (m *ItemMutation) RemovedClustersIDs() (ids []xid.ID) { + for id := range m.removedclusters { + ids = append(ids, id) + } + return +} + +// ClustersIDs returns the "clusters" edge IDs in the mutation. +func (m *ItemMutation) ClustersIDs() (ids []xid.ID) { + for id := range m.clusters { + ids = append(ids, id) + } + return +} + +// ResetClusters resets all changes to the "clusters" edge. +func (m *ItemMutation) ResetClusters() { + m.clusters = nil + m.clearedclusters = false + m.removedclusters = nil +} + +// AddAssetIDs adds the "assets" edge to the Asset entity by ids. +func (m *ItemMutation) AddAssetIDs(ids ...string) { + if m.assets == nil { + m.assets = make(map[string]struct{}) + } + for i := range ids { + m.assets[ids[i]] = struct{}{} + } +} + +// ClearAssets clears the "assets" edge to the Asset entity. +func (m *ItemMutation) ClearAssets() { + m.clearedassets = true +} + +// AssetsCleared reports if the "assets" edge to the Asset entity was cleared. +func (m *ItemMutation) AssetsCleared() bool { + return m.clearedassets +} + +// RemoveAssetIDs removes the "assets" edge to the Asset entity by IDs. +func (m *ItemMutation) RemoveAssetIDs(ids ...string) { + if m.removedassets == nil { + m.removedassets = make(map[string]struct{}) + } + for i := range ids { + delete(m.assets, ids[i]) + m.removedassets[ids[i]] = struct{}{} + } +} + +// RemovedAssets returns the removed IDs of the "assets" edge to the Asset entity. +func (m *ItemMutation) RemovedAssetsIDs() (ids []string) { + for id := range m.removedassets { + ids = append(ids, id) + } + return +} + +// AssetsIDs returns the "assets" edge IDs in the mutation. +func (m *ItemMutation) AssetsIDs() (ids []string) { + for id := range m.assets { + ids = append(ids, id) + } + return +} + +// ResetAssets resets all changes to the "assets" edge. +func (m *ItemMutation) ResetAssets() { + m.assets = nil + m.clearedassets = false + m.removedassets = nil +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *ItemMutation) AddTagIDs(ids ...xid.ID) { + if m.tags == nil { + m.tags = make(map[xid.ID]struct{}) + } + for i := range ids { + m.tags[ids[i]] = struct{}{} + } +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *ItemMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *ItemMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *ItemMutation) RemoveTagIDs(ids ...xid.ID) { + if m.removedtags == nil { + m.removedtags = make(map[xid.ID]struct{}) } for i := range ids { - delete(m.posts, ids[i]) - m.removedposts[ids[i]] = struct{}{} + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} } } -// RemovedPosts returns the removed IDs of the "posts" edge to the Post entity. -func (m *CollectionMutation) RemovedPostsIDs() (ids []xid.ID) { - for id := range m.removedposts { +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *ItemMutation) RemovedTagsIDs() (ids []xid.ID) { + for id := range m.removedtags { ids = append(ids, id) } return } -// PostsIDs returns the "posts" edge IDs in the mutation. -func (m *CollectionMutation) PostsIDs() (ids []xid.ID) { - for id := range m.posts { +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *ItemMutation) TagsIDs() (ids []xid.ID) { + for id := range m.tags { ids = append(ids, id) } return } -// ResetPosts resets all changes to the "posts" edge. -func (m *CollectionMutation) ResetPosts() { - m.posts = nil - m.clearedposts = false - m.removedposts = nil +// ResetTags resets all changes to the "tags" edge. +func (m *ItemMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil } -// Where appends a list predicates to the CollectionMutation builder. -func (m *CollectionMutation) Where(ps ...predicate.Collection) { +// Where appends a list predicates to the ItemMutation builder. +func (m *ItemMutation) Where(ps ...predicate.Item) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the CollectionMutation builder. Using this method, +// WhereP appends storage-level predicates to the ItemMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *CollectionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Collection, len(ps)) +func (m *ItemMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Item, len(ps)) for i := range ps { p[i] = ps[i] } @@ -4142,36 +6570,45 @@ func (m *CollectionMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *CollectionMutation) Op() Op { +func (m *ItemMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *CollectionMutation) SetOp(op Op) { +func (m *ItemMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Collection). -func (m *CollectionMutation) Type() string { +// Type returns the node type of this mutation (Item). +func (m *ItemMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *CollectionMutation) Fields() []string { - fields := make([]string, 0, 4) +func (m *ItemMutation) Fields() []string { + fields := make([]string, 0, 7) if m.created_at != nil { - fields = append(fields, collection.FieldCreatedAt) + fields = append(fields, item.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, collection.FieldUpdatedAt) + fields = append(fields, item.FieldUpdatedAt) } if m.name != nil { - fields = append(fields, collection.FieldName) + fields = append(fields, item.FieldName) + } + if m.slug != nil { + fields = append(fields, item.FieldSlug) + } + if m.image_url != nil { + fields = append(fields, item.FieldImageURL) } if m.description != nil { - fields = append(fields, collection.FieldDescription) + fields = append(fields, item.FieldDescription) + } + if m.owner != nil { + fields = append(fields, item.FieldAccountID) } return fields } @@ -4179,16 +6616,22 @@ func (m *CollectionMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *CollectionMutation) Field(name string) (ent.Value, bool) { +func (m *ItemMutation) Field(name string) (ent.Value, bool) { switch name { - case collection.FieldCreatedAt: + case item.FieldCreatedAt: return m.CreatedAt() - case collection.FieldUpdatedAt: + case item.FieldUpdatedAt: return m.UpdatedAt() - case collection.FieldName: + case item.FieldName: return m.Name() - case collection.FieldDescription: + case item.FieldSlug: + return m.Slug() + case item.FieldImageURL: + return m.ImageURL() + case item.FieldDescription: return m.Description() + case item.FieldAccountID: + return m.AccountID() } return nil, false } @@ -4196,141 +6639,204 @@ func (m *CollectionMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *CollectionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case collection.FieldCreatedAt: + case item.FieldCreatedAt: return m.OldCreatedAt(ctx) - case collection.FieldUpdatedAt: + case item.FieldUpdatedAt: return m.OldUpdatedAt(ctx) - case collection.FieldName: + case item.FieldName: return m.OldName(ctx) - case collection.FieldDescription: + case item.FieldSlug: + return m.OldSlug(ctx) + case item.FieldImageURL: + return m.OldImageURL(ctx) + case item.FieldDescription: return m.OldDescription(ctx) + case item.FieldAccountID: + return m.OldAccountID(ctx) } - return nil, fmt.Errorf("unknown Collection field %s", name) + return nil, fmt.Errorf("unknown Item field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *CollectionMutation) SetField(name string, value ent.Value) error { +func (m *ItemMutation) SetField(name string, value ent.Value) error { switch name { - case collection.FieldCreatedAt: + case item.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case collection.FieldUpdatedAt: + case item.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil - case collection.FieldName: + case item.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil - case collection.FieldDescription: + case item.FieldSlug: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSlug(v) + return nil + case item.FieldImageURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImageURL(v) + return nil + case item.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDescription(v) return nil + case item.FieldAccountID: + v, ok := value.(xid.ID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccountID(v) + return nil } - return fmt.Errorf("unknown Collection field %s", name) + return fmt.Errorf("unknown Item field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *CollectionMutation) AddedFields() []string { +func (m *ItemMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *CollectionMutation) AddedField(name string) (ent.Value, bool) { +func (m *ItemMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *CollectionMutation) AddField(name string, value ent.Value) error { +func (m *ItemMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Collection numeric field %s", name) + return fmt.Errorf("unknown Item numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *CollectionMutation) ClearedFields() []string { - return nil +func (m *ItemMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(item.FieldImageURL) { + fields = append(fields, item.FieldImageURL) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *CollectionMutation) FieldCleared(name string) bool { +func (m *ItemMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *CollectionMutation) ClearField(name string) error { - return fmt.Errorf("unknown Collection nullable field %s", name) +func (m *ItemMutation) ClearField(name string) error { + switch name { + case item.FieldImageURL: + m.ClearImageURL() + return nil + } + return fmt.Errorf("unknown Item nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *CollectionMutation) ResetField(name string) error { +func (m *ItemMutation) ResetField(name string) error { switch name { - case collection.FieldCreatedAt: + case item.FieldCreatedAt: m.ResetCreatedAt() return nil - case collection.FieldUpdatedAt: + case item.FieldUpdatedAt: m.ResetUpdatedAt() return nil - case collection.FieldName: + case item.FieldName: m.ResetName() return nil - case collection.FieldDescription: + case item.FieldSlug: + m.ResetSlug() + return nil + case item.FieldImageURL: + m.ResetImageURL() + return nil + case item.FieldDescription: m.ResetDescription() return nil + case item.FieldAccountID: + m.ResetAccountID() + return nil } - return fmt.Errorf("unknown Collection field %s", name) + return fmt.Errorf("unknown Item field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *CollectionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) +func (m *ItemMutation) AddedEdges() []string { + edges := make([]string, 0, 4) if m.owner != nil { - edges = append(edges, collection.EdgeOwner) + edges = append(edges, item.EdgeOwner) } - if m.posts != nil { - edges = append(edges, collection.EdgePosts) + if m.clusters != nil { + edges = append(edges, item.EdgeClusters) + } + if m.assets != nil { + edges = append(edges, item.EdgeAssets) + } + if m.tags != nil { + edges = append(edges, item.EdgeTags) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *CollectionMutation) AddedIDs(name string) []ent.Value { +func (m *ItemMutation) AddedIDs(name string) []ent.Value { switch name { - case collection.EdgeOwner: + case item.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } - case collection.EdgePosts: - ids := make([]ent.Value, 0, len(m.posts)) - for id := range m.posts { + case item.EdgeClusters: + ids := make([]ent.Value, 0, len(m.clusters)) + for id := range m.clusters { + ids = append(ids, id) + } + return ids + case item.EdgeAssets: + ids := make([]ent.Value, 0, len(m.assets)) + for id := range m.assets { + ids = append(ids, id) + } + return ids + case item.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { ids = append(ids, id) } return ids @@ -4339,21 +6845,39 @@ func (m *CollectionMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *CollectionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedposts != nil { - edges = append(edges, collection.EdgePosts) +func (m *ItemMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedclusters != nil { + edges = append(edges, item.EdgeClusters) + } + if m.removedassets != nil { + edges = append(edges, item.EdgeAssets) + } + if m.removedtags != nil { + edges = append(edges, item.EdgeTags) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *CollectionMutation) RemovedIDs(name string) []ent.Value { +func (m *ItemMutation) RemovedIDs(name string) []ent.Value { switch name { - case collection.EdgePosts: - ids := make([]ent.Value, 0, len(m.removedposts)) - for id := range m.removedposts { + case item.EdgeClusters: + ids := make([]ent.Value, 0, len(m.removedclusters)) + for id := range m.removedclusters { + ids = append(ids, id) + } + return ids + case item.EdgeAssets: + ids := make([]ent.Value, 0, len(m.removedassets)) + for id := range m.removedassets { + ids = append(ids, id) + } + return ids + case item.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { ids = append(ids, id) } return ids @@ -4362,52 +6886,68 @@ func (m *CollectionMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CollectionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) +func (m *ItemMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) if m.clearedowner { - edges = append(edges, collection.EdgeOwner) + edges = append(edges, item.EdgeOwner) } - if m.clearedposts { - edges = append(edges, collection.EdgePosts) + if m.clearedclusters { + edges = append(edges, item.EdgeClusters) + } + if m.clearedassets { + edges = append(edges, item.EdgeAssets) + } + if m.clearedtags { + edges = append(edges, item.EdgeTags) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *CollectionMutation) EdgeCleared(name string) bool { +func (m *ItemMutation) EdgeCleared(name string) bool { switch name { - case collection.EdgeOwner: + case item.EdgeOwner: return m.clearedowner - case collection.EdgePosts: - return m.clearedposts + case item.EdgeClusters: + return m.clearedclusters + case item.EdgeAssets: + return m.clearedassets + case item.EdgeTags: + return m.clearedtags } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *CollectionMutation) ClearEdge(name string) error { +func (m *ItemMutation) ClearEdge(name string) error { switch name { - case collection.EdgeOwner: + case item.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown Collection unique edge %s", name) + return fmt.Errorf("unknown Item unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *CollectionMutation) ResetEdge(name string) error { +func (m *ItemMutation) ResetEdge(name string) error { switch name { - case collection.EdgeOwner: + case item.EdgeOwner: m.ResetOwner() return nil - case collection.EdgePosts: - m.ResetPosts() + case item.EdgeClusters: + m.ResetClusters() + return nil + case item.EdgeAssets: + m.ResetAssets() + return nil + case item.EdgeTags: + m.ResetTags() return nil } - return fmt.Errorf("unknown Collection edge %s", name) + return fmt.Errorf("unknown Item edge %s", name) } // NotificationMutation represents an operation that mutates the Notification nodes in the graph. @@ -8452,6 +10992,12 @@ type TagMutation struct { posts map[xid.ID]struct{} removedposts map[xid.ID]struct{} clearedposts bool + clusters map[xid.ID]struct{} + removedclusters map[xid.ID]struct{} + clearedclusters bool + items map[xid.ID]struct{} + removeditems map[xid.ID]struct{} + cleareditems bool accounts map[xid.ID]struct{} removedaccounts map[xid.ID]struct{} clearedaccounts bool @@ -8690,6 +11236,114 @@ func (m *TagMutation) ResetPosts() { m.removedposts = nil } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by ids. +func (m *TagMutation) AddClusterIDs(ids ...xid.ID) { + if m.clusters == nil { + m.clusters = make(map[xid.ID]struct{}) + } + for i := range ids { + m.clusters[ids[i]] = struct{}{} + } +} + +// ClearClusters clears the "clusters" edge to the Cluster entity. +func (m *TagMutation) ClearClusters() { + m.clearedclusters = true +} + +// ClustersCleared reports if the "clusters" edge to the Cluster entity was cleared. +func (m *TagMutation) ClustersCleared() bool { + return m.clearedclusters +} + +// RemoveClusterIDs removes the "clusters" edge to the Cluster entity by IDs. +func (m *TagMutation) RemoveClusterIDs(ids ...xid.ID) { + if m.removedclusters == nil { + m.removedclusters = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.clusters, ids[i]) + m.removedclusters[ids[i]] = struct{}{} + } +} + +// RemovedClusters returns the removed IDs of the "clusters" edge to the Cluster entity. +func (m *TagMutation) RemovedClustersIDs() (ids []xid.ID) { + for id := range m.removedclusters { + ids = append(ids, id) + } + return +} + +// ClustersIDs returns the "clusters" edge IDs in the mutation. +func (m *TagMutation) ClustersIDs() (ids []xid.ID) { + for id := range m.clusters { + ids = append(ids, id) + } + return +} + +// ResetClusters resets all changes to the "clusters" edge. +func (m *TagMutation) ResetClusters() { + m.clusters = nil + m.clearedclusters = false + m.removedclusters = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *TagMutation) AddItemIDs(ids ...xid.ID) { + if m.items == nil { + m.items = make(map[xid.ID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *TagMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *TagMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *TagMutation) RemoveItemIDs(ids ...xid.ID) { + if m.removeditems == nil { + m.removeditems = make(map[xid.ID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *TagMutation) RemovedItemsIDs() (ids []xid.ID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *TagMutation) ItemsIDs() (ids []xid.ID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *TagMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil +} + // AddAccountIDs adds the "accounts" edge to the Account entity by ids. func (m *TagMutation) AddAccountIDs(ids ...xid.ID) { if m.accounts == nil { @@ -8894,10 +11548,16 @@ func (m *TagMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TagMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.posts != nil { edges = append(edges, tag.EdgePosts) } + if m.clusters != nil { + edges = append(edges, tag.EdgeClusters) + } + if m.items != nil { + edges = append(edges, tag.EdgeItems) + } if m.accounts != nil { edges = append(edges, tag.EdgeAccounts) } @@ -8914,6 +11574,18 @@ func (m *TagMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case tag.EdgeClusters: + ids := make([]ent.Value, 0, len(m.clusters)) + for id := range m.clusters { + ids = append(ids, id) + } + return ids + case tag.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { + ids = append(ids, id) + } + return ids case tag.EdgeAccounts: ids := make([]ent.Value, 0, len(m.accounts)) for id := range m.accounts { @@ -8926,10 +11598,16 @@ func (m *TagMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *TagMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.removedposts != nil { edges = append(edges, tag.EdgePosts) } + if m.removedclusters != nil { + edges = append(edges, tag.EdgeClusters) + } + if m.removeditems != nil { + edges = append(edges, tag.EdgeItems) + } if m.removedaccounts != nil { edges = append(edges, tag.EdgeAccounts) } @@ -8946,6 +11624,18 @@ func (m *TagMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case tag.EdgeClusters: + ids := make([]ent.Value, 0, len(m.removedclusters)) + for id := range m.removedclusters { + ids = append(ids, id) + } + return ids + case tag.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { + ids = append(ids, id) + } + return ids case tag.EdgeAccounts: ids := make([]ent.Value, 0, len(m.removedaccounts)) for id := range m.removedaccounts { @@ -8958,10 +11648,16 @@ func (m *TagMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TagMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 4) if m.clearedposts { edges = append(edges, tag.EdgePosts) } + if m.clearedclusters { + edges = append(edges, tag.EdgeClusters) + } + if m.cleareditems { + edges = append(edges, tag.EdgeItems) + } if m.clearedaccounts { edges = append(edges, tag.EdgeAccounts) } @@ -8974,6 +11670,10 @@ func (m *TagMutation) EdgeCleared(name string) bool { switch name { case tag.EdgePosts: return m.clearedposts + case tag.EdgeClusters: + return m.clearedclusters + case tag.EdgeItems: + return m.cleareditems case tag.EdgeAccounts: return m.clearedaccounts } @@ -8995,6 +11695,12 @@ func (m *TagMutation) ResetEdge(name string) error { case tag.EdgePosts: m.ResetPosts() return nil + case tag.EdgeClusters: + m.ResetClusters() + return nil + case tag.EdgeItems: + m.ResetItems() + return nil case tag.EdgeAccounts: m.ResetAccounts() return nil diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go index 113db4f9a..e607e5507 100644 --- a/internal/ent/predicate/predicate.go +++ b/internal/ent/predicate/predicate.go @@ -18,9 +18,15 @@ type Authentication func(*sql.Selector) // Category is the predicate function for category builders. type Category func(*sql.Selector) +// Cluster is the predicate function for cluster builders. +type Cluster func(*sql.Selector) + // Collection is the predicate function for collection builders. type Collection func(*sql.Selector) +// Item is the predicate function for item builders. +type Item func(*sql.Selector) + // Notification is the predicate function for notification builders. type Notification func(*sql.Selector) diff --git a/internal/ent/runtime.go b/internal/ent/runtime.go index 9f0ff2abd..3978f682a 100644 --- a/internal/ent/runtime.go +++ b/internal/ent/runtime.go @@ -9,7 +9,9 @@ import ( "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/authentication" "github.com/Southclaws/storyden/internal/ent/category" + "github.com/Southclaws/storyden/internal/ent/cluster" "github.com/Southclaws/storyden/internal/ent/collection" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/notification" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/react" @@ -190,6 +192,45 @@ func init() { return nil } }() + clusterMixin := schema.Cluster{}.Mixin() + clusterMixinFields0 := clusterMixin[0].Fields() + _ = clusterMixinFields0 + clusterMixinFields1 := clusterMixin[1].Fields() + _ = clusterMixinFields1 + clusterMixinFields2 := clusterMixin[2].Fields() + _ = clusterMixinFields2 + clusterFields := schema.Cluster{}.Fields() + _ = clusterFields + // clusterDescCreatedAt is the schema descriptor for created_at field. + clusterDescCreatedAt := clusterMixinFields1[0].Descriptor() + // cluster.DefaultCreatedAt holds the default value on creation for the created_at field. + cluster.DefaultCreatedAt = clusterDescCreatedAt.Default.(func() time.Time) + // clusterDescUpdatedAt is the schema descriptor for updated_at field. + clusterDescUpdatedAt := clusterMixinFields2[0].Descriptor() + // cluster.DefaultUpdatedAt holds the default value on creation for the updated_at field. + cluster.DefaultUpdatedAt = clusterDescUpdatedAt.Default.(func() time.Time) + // cluster.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + cluster.UpdateDefaultUpdatedAt = clusterDescUpdatedAt.UpdateDefault.(func() time.Time) + // clusterDescID is the schema descriptor for id field. + clusterDescID := clusterMixinFields0[0].Descriptor() + // cluster.DefaultID holds the default value on creation for the id field. + cluster.DefaultID = clusterDescID.Default.(func() xid.ID) + // cluster.IDValidator is a validator for the "id" field. It is called by the builders before save. + cluster.IDValidator = func() func(string) error { + validators := clusterDescID.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(id string) error { + for _, fn := range fns { + if err := fn(id); err != nil { + return err + } + } + return nil + } + }() collectionMixin := schema.Collection{}.Mixin() collectionMixinFields0 := collectionMixin[0].Fields() _ = collectionMixinFields0 @@ -229,6 +270,45 @@ func init() { return nil } }() + itemMixin := schema.Item{}.Mixin() + itemMixinFields0 := itemMixin[0].Fields() + _ = itemMixinFields0 + itemMixinFields1 := itemMixin[1].Fields() + _ = itemMixinFields1 + itemMixinFields2 := itemMixin[2].Fields() + _ = itemMixinFields2 + itemFields := schema.Item{}.Fields() + _ = itemFields + // itemDescCreatedAt is the schema descriptor for created_at field. + itemDescCreatedAt := itemMixinFields1[0].Descriptor() + // item.DefaultCreatedAt holds the default value on creation for the created_at field. + item.DefaultCreatedAt = itemDescCreatedAt.Default.(func() time.Time) + // itemDescUpdatedAt is the schema descriptor for updated_at field. + itemDescUpdatedAt := itemMixinFields2[0].Descriptor() + // item.DefaultUpdatedAt holds the default value on creation for the updated_at field. + item.DefaultUpdatedAt = itemDescUpdatedAt.Default.(func() time.Time) + // item.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + item.UpdateDefaultUpdatedAt = itemDescUpdatedAt.UpdateDefault.(func() time.Time) + // itemDescID is the schema descriptor for id field. + itemDescID := itemMixinFields0[0].Descriptor() + // item.DefaultID holds the default value on creation for the id field. + item.DefaultID = itemDescID.Default.(func() xid.ID) + // item.IDValidator is a validator for the "id" field. It is called by the builders before save. + item.IDValidator = func() func(string) error { + validators := itemDescID.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(id string) error { + for _, fn := range fns { + if err := fn(id); err != nil { + return err + } + } + return nil + } + }() notificationMixin := schema.Notification{}.Mixin() notificationMixinFields0 := notificationMixin[0].Fields() _ = notificationMixinFields0 diff --git a/internal/ent/schema/account.go b/internal/ent/schema/account.go index 7a2fe874f..a8aad8bb7 100644 --- a/internal/ent/schema/account.go +++ b/internal/ent/schema/account.go @@ -38,6 +38,10 @@ func (Account) Edges() []ent.Edge { edge.To("collections", Collection.Type), + edge.To("clusters", Cluster.Type), + + edge.To("items", Item.Type), + edge.To("assets", Asset.Type), } } diff --git a/internal/ent/schema/asset.go b/internal/ent/schema/asset.go index 642f9bfd2..7ac21f885 100644 --- a/internal/ent/schema/asset.go +++ b/internal/ent/schema/asset.go @@ -37,6 +37,12 @@ func (Asset) Edges() []ent.Edge { edge.From("posts", Post.Type). Ref("assets"), + edge.From("clusters", Cluster.Type). + Ref("assets"), + + edge.From("items", Item.Type). + Ref("assets"), + edge.From("owner", Account.Type). Field("account_id"). Ref("assets"). diff --git a/internal/ent/schema/cluster.go b/internal/ent/schema/cluster.go new file mode 100644 index 000000000..58a91e003 --- /dev/null +++ b/internal/ent/schema/cluster.go @@ -0,0 +1,50 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "github.com/rs/xid" +) + +type Cluster struct { + ent.Schema +} + +func (Cluster) Mixin() []ent.Mixin { + return []ent.Mixin{Identifier{}, CreatedAt{}, UpdatedAt{}} +} + +func (Cluster) Fields() []ent.Field { + return []ent.Field{ + field.String("name"), + field.String("slug"), + field.String("image_url").Optional().Nillable(), + field.String("description"), + field.String("parent_cluster_id").GoType(xid.ID{}).Optional(), + field.String("account_id").GoType(xid.ID{}), + } +} + +func (Cluster) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("owner", Account.Type). + Ref("clusters"). + Field("account_id"). + Unique(). + Required(), + + edge.To("clusters", Cluster.Type). + From("parent"). + Unique(). + Field("parent_cluster_id"). + Comment("A many-to-many recursive self reference. The parent cluster, if any."), + + edge.To("items", Item.Type), + + edge.To("assets", Asset.Type), + + edge.From("tags", Tag.Type). + Ref("clusters"), + } +} diff --git a/internal/ent/schema/item.go b/internal/ent/schema/item.go new file mode 100644 index 000000000..fed699db3 --- /dev/null +++ b/internal/ent/schema/item.go @@ -0,0 +1,44 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "github.com/rs/xid" +) + +type Item struct { + ent.Schema +} + +func (Item) Mixin() []ent.Mixin { + return []ent.Mixin{Identifier{}, CreatedAt{}, UpdatedAt{}} +} + +func (Item) Fields() []ent.Field { + return []ent.Field{ + field.String("name"), + field.String("slug"), + field.String("image_url").Optional().Nillable(), + field.String("description"), + field.String("account_id").GoType(xid.ID{}), + } +} + +func (Item) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("owner", Account.Type). + Ref("items"). + Field("account_id"). + Unique(). + Required(), + + edge.From("clusters", Cluster.Type). + Ref("items"), + + edge.To("assets", Asset.Type), + + edge.From("tags", Tag.Type). + Ref("items"), + } +} diff --git a/internal/ent/schema/tag.go b/internal/ent/schema/tag.go index 78bbd8499..5cff4a680 100644 --- a/internal/ent/schema/tag.go +++ b/internal/ent/schema/tag.go @@ -25,6 +25,8 @@ func (Tag) Fields() []ent.Field { func (Tag) Edges() []ent.Edge { return []ent.Edge{ edge.To("posts", Post.Type), + edge.To("clusters", Cluster.Type), + edge.To("items", Item.Type), edge.From("accounts", Account.Type). Ref("tags"), } diff --git a/internal/ent/tag.go b/internal/ent/tag.go index e328066e9..093dac6d6 100644 --- a/internal/ent/tag.go +++ b/internal/ent/tag.go @@ -30,11 +30,15 @@ type Tag struct { type TagEdges struct { // Posts holds the value of the posts edge. Posts []*Post `json:"posts,omitempty"` + // Clusters holds the value of the clusters edge. + Clusters []*Cluster `json:"clusters,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` // Accounts holds the value of the accounts edge. Accounts []*Account `json:"accounts,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [4]bool } // PostsOrErr returns the Posts value or an error if the edge @@ -46,10 +50,28 @@ func (e TagEdges) PostsOrErr() ([]*Post, error) { return nil, &NotLoadedError{edge: "posts"} } +// ClustersOrErr returns the Clusters value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) ClustersOrErr() ([]*Cluster, error) { + if e.loadedTypes[1] { + return e.Clusters, nil + } + return nil, &NotLoadedError{edge: "clusters"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[2] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} +} + // AccountsOrErr returns the Accounts value or an error if the edge // was not loaded in eager-loading. func (e TagEdges) AccountsOrErr() ([]*Account, error) { - if e.loadedTypes[1] { + if e.loadedTypes[3] { return e.Accounts, nil } return nil, &NotLoadedError{edge: "accounts"} @@ -109,6 +131,16 @@ func (t *Tag) QueryPosts() *PostQuery { return NewTagClient(t.config).QueryPosts(t) } +// QueryClusters queries the "clusters" edge of the Tag entity. +func (t *Tag) QueryClusters() *ClusterQuery { + return NewTagClient(t.config).QueryClusters(t) +} + +// QueryItems queries the "items" edge of the Tag entity. +func (t *Tag) QueryItems() *ItemQuery { + return NewTagClient(t.config).QueryItems(t) +} + // QueryAccounts queries the "accounts" edge of the Tag entity. func (t *Tag) QueryAccounts() *AccountQuery { return NewTagClient(t.config).QueryAccounts(t) diff --git a/internal/ent/tag/tag.go b/internal/ent/tag/tag.go index e8ba4f8cf..12f7ce762 100644 --- a/internal/ent/tag/tag.go +++ b/internal/ent/tag/tag.go @@ -19,6 +19,10 @@ const ( FieldName = "name" // EdgePosts holds the string denoting the posts edge name in mutations. EdgePosts = "posts" + // EdgeClusters holds the string denoting the clusters edge name in mutations. + EdgeClusters = "clusters" + // EdgeItems holds the string denoting the items edge name in mutations. + EdgeItems = "items" // EdgeAccounts holds the string denoting the accounts edge name in mutations. EdgeAccounts = "accounts" // Table holds the table name of the tag in the database. @@ -28,6 +32,16 @@ const ( // PostsInverseTable is the table name for the Post entity. // It exists in this package in order to avoid circular dependency with the "post" package. PostsInverseTable = "posts" + // ClustersTable is the table that holds the clusters relation/edge. The primary key declared below. + ClustersTable = "tag_clusters" + // ClustersInverseTable is the table name for the Cluster entity. + // It exists in this package in order to avoid circular dependency with the "cluster" package. + ClustersInverseTable = "clusters" + // ItemsTable is the table that holds the items relation/edge. The primary key declared below. + ItemsTable = "tag_items" + // ItemsInverseTable is the table name for the Item entity. + // It exists in this package in order to avoid circular dependency with the "item" package. + ItemsInverseTable = "items" // AccountsTable is the table that holds the accounts relation/edge. The primary key declared below. AccountsTable = "account_tags" // AccountsInverseTable is the table name for the Account entity. @@ -46,6 +60,12 @@ var ( // PostsPrimaryKey and PostsColumn2 are the table columns denoting the // primary key for the posts relation (M2M). PostsPrimaryKey = []string{"tag_id", "post_id"} + // ClustersPrimaryKey and ClustersColumn2 are the table columns denoting the + // primary key for the clusters relation (M2M). + ClustersPrimaryKey = []string{"tag_id", "cluster_id"} + // ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the + // primary key for the items relation (M2M). + ItemsPrimaryKey = []string{"tag_id", "item_id"} // AccountsPrimaryKey and AccountsColumn2 are the table columns denoting the // primary key for the accounts relation (M2M). AccountsPrimaryKey = []string{"account_id", "tag_id"} diff --git a/internal/ent/tag/where.go b/internal/ent/tag/where.go index b35a8b2dc..55b860c55 100644 --- a/internal/ent/tag/where.go +++ b/internal/ent/tag/where.go @@ -198,6 +198,60 @@ func HasPostsWith(preds ...predicate.Post) predicate.Tag { }) } +// HasClusters applies the HasEdge predicate on the "clusters" edge. +func HasClusters() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasClustersWith applies the HasEdge predicate on the "clusters" edge with a given conditions (other predicates). +func HasClustersWith(preds ...predicate.Cluster) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ClustersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ClustersTable, ClustersPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasItems applies the HasEdge predicate on the "items" edge. +func HasItems() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). +func HasItemsWith(preds ...predicate.Item) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasAccounts applies the HasEdge predicate on the "accounts" edge. func HasAccounts() predicate.Tag { return predicate.Tag(func(s *sql.Selector) { diff --git a/internal/ent/tag_create.go b/internal/ent/tag_create.go index 6ce23bdbd..896828e38 100644 --- a/internal/ent/tag_create.go +++ b/internal/ent/tag_create.go @@ -13,6 +13,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/tag" "github.com/rs/xid" @@ -75,6 +77,36 @@ func (tc *TagCreate) AddPosts(p ...*Post) *TagCreate { return tc.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (tc *TagCreate) AddClusterIDs(ids ...xid.ID) *TagCreate { + tc.mutation.AddClusterIDs(ids...) + return tc +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (tc *TagCreate) AddClusters(c ...*Cluster) *TagCreate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return tc.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (tc *TagCreate) AddItemIDs(ids ...xid.ID) *TagCreate { + tc.mutation.AddItemIDs(ids...) + return tc +} + +// AddItems adds the "items" edges to the Item entity. +func (tc *TagCreate) AddItems(i ...*Item) *TagCreate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return tc.AddItemIDs(ids...) +} + // AddAccountIDs adds the "accounts" edge to the Account entity by IDs. func (tc *TagCreate) AddAccountIDs(ids ...xid.ID) *TagCreate { tc.mutation.AddAccountIDs(ids...) @@ -208,6 +240,38 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := tc.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := tc.mutation.AccountsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/internal/ent/tag_query.go b/internal/ent/tag_query.go index c64d14dc0..2ae7b13c3 100644 --- a/internal/ent/tag_query.go +++ b/internal/ent/tag_query.go @@ -12,6 +12,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/Southclaws/storyden/internal/ent/tag" @@ -26,6 +28,8 @@ type TagQuery struct { inters []Interceptor predicates []predicate.Tag withPosts *PostQuery + withClusters *ClusterQuery + withItems *ItemQuery withAccounts *AccountQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). @@ -86,6 +90,50 @@ func (tq *TagQuery) QueryPosts() *PostQuery { return query } +// QueryClusters chains the current query on the "clusters" edge. +func (tq *TagQuery) QueryClusters() *ClusterQuery { + query := (&ClusterClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, selector), + sqlgraph.To(cluster.Table, cluster.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, tag.ClustersTable, tag.ClustersPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (tq *TagQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, tag.ItemsTable, tag.ItemsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryAccounts chains the current query on the "accounts" edge. func (tq *TagQuery) QueryAccounts() *AccountQuery { query := (&AccountClient{config: tq.config}).Query() @@ -301,6 +349,8 @@ func (tq *TagQuery) Clone() *TagQuery { inters: append([]Interceptor{}, tq.inters...), predicates: append([]predicate.Tag{}, tq.predicates...), withPosts: tq.withPosts.Clone(), + withClusters: tq.withClusters.Clone(), + withItems: tq.withItems.Clone(), withAccounts: tq.withAccounts.Clone(), // clone intermediate query. sql: tq.sql.Clone(), @@ -319,6 +369,28 @@ func (tq *TagQuery) WithPosts(opts ...func(*PostQuery)) *TagQuery { return tq } +// WithClusters tells the query-builder to eager-load the nodes that are connected to +// the "clusters" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithClusters(opts ...func(*ClusterQuery)) *TagQuery { + query := (&ClusterClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withClusters = query + return tq +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithItems(opts ...func(*ItemQuery)) *TagQuery { + query := (&ItemClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withItems = query + return tq +} + // WithAccounts tells the query-builder to eager-load the nodes that are connected to // the "accounts" edge. The optional arguments are used to configure the query builder of the edge. func (tq *TagQuery) WithAccounts(opts ...func(*AccountQuery)) *TagQuery { @@ -408,8 +480,10 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err var ( nodes = []*Tag{} _spec = tq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [4]bool{ tq.withPosts != nil, + tq.withClusters != nil, + tq.withItems != nil, tq.withAccounts != nil, } ) @@ -441,6 +515,20 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err return nil, err } } + if query := tq.withClusters; query != nil { + if err := tq.loadClusters(ctx, query, nodes, + func(n *Tag) { n.Edges.Clusters = []*Cluster{} }, + func(n *Tag, e *Cluster) { n.Edges.Clusters = append(n.Edges.Clusters, e) }); err != nil { + return nil, err + } + } + if query := tq.withItems; query != nil { + if err := tq.loadItems(ctx, query, nodes, + func(n *Tag) { n.Edges.Items = []*Item{} }, + func(n *Tag, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + return nil, err + } + } if query := tq.withAccounts; query != nil { if err := tq.loadAccounts(ctx, query, nodes, func(n *Tag) { n.Edges.Accounts = []*Account{} }, @@ -512,6 +600,128 @@ func (tq *TagQuery) loadPosts(ctx context.Context, query *PostQuery, nodes []*Ta } return nil } +func (tq *TagQuery) loadClusters(ctx context.Context, query *ClusterQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Cluster)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Tag) + nids := make(map[xid.ID]map[*Tag]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(tag.ClustersTable) + s.Join(joinT).On(s.C(cluster.FieldID), joinT.C(tag.ClustersPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(tag.ClustersPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(tag.ClustersPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Tag]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Cluster](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "clusters" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (tq *TagQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Item)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[xid.ID]*Tag) + nids := make(map[xid.ID]map[*Tag]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(tag.ItemsTable) + s.Join(joinT).On(s.C(item.FieldID), joinT.C(tag.ItemsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(tag.ItemsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(tag.ItemsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(xid.ID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*xid.ID) + inValue := *values[1].(*xid.ID) + if nids[inValue] == nil { + nids[inValue] = map[*Tag]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "items" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (tq *TagQuery) loadAccounts(ctx context.Context, query *AccountQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Account)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[xid.ID]*Tag) diff --git a/internal/ent/tag_update.go b/internal/ent/tag_update.go index e3b7df50c..2f9bb9504 100644 --- a/internal/ent/tag_update.go +++ b/internal/ent/tag_update.go @@ -11,6 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" + "github.com/Southclaws/storyden/internal/ent/cluster" + "github.com/Southclaws/storyden/internal/ent/item" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/Southclaws/storyden/internal/ent/tag" @@ -46,6 +48,36 @@ func (tu *TagUpdate) AddPosts(p ...*Post) *TagUpdate { return tu.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (tu *TagUpdate) AddClusterIDs(ids ...xid.ID) *TagUpdate { + tu.mutation.AddClusterIDs(ids...) + return tu +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (tu *TagUpdate) AddClusters(c ...*Cluster) *TagUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return tu.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (tu *TagUpdate) AddItemIDs(ids ...xid.ID) *TagUpdate { + tu.mutation.AddItemIDs(ids...) + return tu +} + +// AddItems adds the "items" edges to the Item entity. +func (tu *TagUpdate) AddItems(i ...*Item) *TagUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return tu.AddItemIDs(ids...) +} + // AddAccountIDs adds the "accounts" edge to the Account entity by IDs. func (tu *TagUpdate) AddAccountIDs(ids ...xid.ID) *TagUpdate { tu.mutation.AddAccountIDs(ids...) @@ -87,6 +119,48 @@ func (tu *TagUpdate) RemovePosts(p ...*Post) *TagUpdate { return tu.RemovePostIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (tu *TagUpdate) ClearClusters() *TagUpdate { + tu.mutation.ClearClusters() + return tu +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (tu *TagUpdate) RemoveClusterIDs(ids ...xid.ID) *TagUpdate { + tu.mutation.RemoveClusterIDs(ids...) + return tu +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (tu *TagUpdate) RemoveClusters(c ...*Cluster) *TagUpdate { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return tu.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (tu *TagUpdate) ClearItems() *TagUpdate { + tu.mutation.ClearItems() + return tu +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (tu *TagUpdate) RemoveItemIDs(ids ...xid.ID) *TagUpdate { + tu.mutation.RemoveItemIDs(ids...) + return tu +} + +// RemoveItems removes "items" edges to Item entities. +func (tu *TagUpdate) RemoveItems(i ...*Item) *TagUpdate { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return tu.RemoveItemIDs(ids...) +} + // ClearAccounts clears all "accounts" edges to the Account entity. func (tu *TagUpdate) ClearAccounts() *TagUpdate { tu.mutation.ClearAccounts() @@ -195,6 +269,96 @@ func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedClustersIDs(); len(nodes) > 0 && !tu.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tu.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedItemsIDs(); len(nodes) > 0 && !tu.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if tu.mutation.AccountsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -277,6 +441,36 @@ func (tuo *TagUpdateOne) AddPosts(p ...*Post) *TagUpdateOne { return tuo.AddPostIDs(ids...) } +// AddClusterIDs adds the "clusters" edge to the Cluster entity by IDs. +func (tuo *TagUpdateOne) AddClusterIDs(ids ...xid.ID) *TagUpdateOne { + tuo.mutation.AddClusterIDs(ids...) + return tuo +} + +// AddClusters adds the "clusters" edges to the Cluster entity. +func (tuo *TagUpdateOne) AddClusters(c ...*Cluster) *TagUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return tuo.AddClusterIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (tuo *TagUpdateOne) AddItemIDs(ids ...xid.ID) *TagUpdateOne { + tuo.mutation.AddItemIDs(ids...) + return tuo +} + +// AddItems adds the "items" edges to the Item entity. +func (tuo *TagUpdateOne) AddItems(i ...*Item) *TagUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return tuo.AddItemIDs(ids...) +} + // AddAccountIDs adds the "accounts" edge to the Account entity by IDs. func (tuo *TagUpdateOne) AddAccountIDs(ids ...xid.ID) *TagUpdateOne { tuo.mutation.AddAccountIDs(ids...) @@ -318,6 +512,48 @@ func (tuo *TagUpdateOne) RemovePosts(p ...*Post) *TagUpdateOne { return tuo.RemovePostIDs(ids...) } +// ClearClusters clears all "clusters" edges to the Cluster entity. +func (tuo *TagUpdateOne) ClearClusters() *TagUpdateOne { + tuo.mutation.ClearClusters() + return tuo +} + +// RemoveClusterIDs removes the "clusters" edge to Cluster entities by IDs. +func (tuo *TagUpdateOne) RemoveClusterIDs(ids ...xid.ID) *TagUpdateOne { + tuo.mutation.RemoveClusterIDs(ids...) + return tuo +} + +// RemoveClusters removes "clusters" edges to Cluster entities. +func (tuo *TagUpdateOne) RemoveClusters(c ...*Cluster) *TagUpdateOne { + ids := make([]xid.ID, len(c)) + for i := range c { + ids[i] = c[i].ID + } + return tuo.RemoveClusterIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (tuo *TagUpdateOne) ClearItems() *TagUpdateOne { + tuo.mutation.ClearItems() + return tuo +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (tuo *TagUpdateOne) RemoveItemIDs(ids ...xid.ID) *TagUpdateOne { + tuo.mutation.RemoveItemIDs(ids...) + return tuo +} + +// RemoveItems removes "items" edges to Item entities. +func (tuo *TagUpdateOne) RemoveItems(i ...*Item) *TagUpdateOne { + ids := make([]xid.ID, len(i)) + for j := range i { + ids[j] = i[j].ID + } + return tuo.RemoveItemIDs(ids...) +} + // ClearAccounts clears all "accounts" edges to the Account entity. func (tuo *TagUpdateOne) ClearAccounts() *TagUpdateOne { tuo.mutation.ClearAccounts() @@ -456,6 +692,96 @@ func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedClustersIDs(); len(nodes) > 0 && !tuo.mutation.ClustersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.ClustersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ClustersTable, + Columns: tag.ClustersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(cluster.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tuo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedItemsIDs(); len(nodes) > 0 && !tuo.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: tag.ItemsTable, + Columns: tag.ItemsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if tuo.mutation.AccountsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/internal/ent/tx.go b/internal/ent/tx.go index 6d263ac81..c257947a2 100644 --- a/internal/ent/tx.go +++ b/internal/ent/tx.go @@ -20,8 +20,12 @@ type Tx struct { Authentication *AuthenticationClient // Category is the client for interacting with the Category builders. Category *CategoryClient + // Cluster is the client for interacting with the Cluster builders. + Cluster *ClusterClient // Collection is the client for interacting with the Collection builders. Collection *CollectionClient + // Item is the client for interacting with the Item builders. + Item *ItemClient // Notification is the client for interacting with the Notification builders. Notification *NotificationClient // Post is the client for interacting with the Post builders. @@ -169,7 +173,9 @@ func (tx *Tx) init() { tx.Asset = NewAssetClient(tx.config) tx.Authentication = NewAuthenticationClient(tx.config) tx.Category = NewCategoryClient(tx.config) + tx.Cluster = NewClusterClient(tx.config) tx.Collection = NewCollectionClient(tx.config) + tx.Item = NewItemClient(tx.config) tx.Notification = NewNotificationClient(tx.config) tx.Post = NewPostClient(tx.config) tx.React = NewReactClient(tx.config) diff --git a/internal/openapi/generated.go b/internal/openapi/generated.go index da6dfe7c6..6f3e4b1e8 100644 --- a/internal/openapi/generated.go +++ b/internal/openapi/generated.go @@ -262,6 +262,9 @@ type AssetID = Identifier // AssetList defines model for AssetList. type AssetList = []Asset +// AssetURL The URL of an asset uploaded to the platform. +type AssetURL = string + // AttestationConveyancePreference https://www.w3.org/TR/webauthn-2/#enum-attestation-convey type AttestationConveyancePreference string @@ -459,6 +462,193 @@ type CategorySlug = string // CategorySlugList A list of category names. type CategorySlugList = []CategorySlug +// Cluster defines model for Cluster. +type Cluster struct { + // CreatedAt The time the resource was created. + CreatedAt time.Time `json:"createdAt"` + + // DeletedAt The time the resource was soft-deleted. + DeletedAt *time.Time `json:"deletedAt,omitempty"` + Description ClusterDescription `json:"description"` + + // Id A unique identifier for this resource. + Id Identifier `json:"id"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + + // Misc Arbitrary extra data stored with the resource. + Misc *map[string]interface{} `json:"misc,omitempty"` + Name ClusterName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ClusterSlug `json:"slug"` + + // UpdatedAt The time the resource was updated. + UpdatedAt time.Time `json:"updatedAt"` +} + +// ClusterCommonProps The main properties of a cluster. +type ClusterCommonProps struct { + Description ClusterDescription `json:"description"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name ClusterName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ClusterSlug `json:"slug"` +} + +// ClusterDescription defines model for ClusterDescription. +type ClusterDescription = string + +// ClusterInitialProps defines model for ClusterInitialProps. +type ClusterInitialProps struct { + Description ClusterDescription `json:"description"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name ClusterName `json:"name"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ClusterSlug `json:"slug"` +} + +// ClusterItem An item is an arbitrary object used for indexing any kind of structured +// data for the purposes of archival, search, documentation, products, etc. +// Items are similar to posts in terms of data model but are semantically +// different when it comes to purpose. +// +// If you were to use Storyden to run a community for a video game for +// example, items could be used to represent actual items from the game +// which allows members to search for them as well as reference them in +// posts and other content. +type ClusterItem = Item + +// ClusterItemList A list of items within the context of belonging to a cluster. Different +// from an ItemList because we do not need to include the parent cluster +// information inside each item since it's already available. +type ClusterItemList = []ClusterItem + +// ClusterList defines model for ClusterList. +type ClusterList = []Cluster + +// ClusterMutableProps Note: Properties are replace-all and are not merged with existing. +type ClusterMutableProps struct { + Description *ClusterDescription `json:"description,omitempty"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name *ClusterName `json:"name,omitempty"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug *ClusterSlug `json:"slug,omitempty"` +} + +// ClusterName defines model for ClusterName. +type ClusterName = string + +// ClusterSlug A URL-safe slug for uniquely identifying resources. +type ClusterSlug = Slug + +// ClusterWithItems defines model for ClusterWithItems. +type ClusterWithItems struct { + Clusters ClusterList `json:"clusters"` + + // CreatedAt The time the resource was created. + CreatedAt time.Time `json:"createdAt"` + + // DeletedAt The time the resource was soft-deleted. + DeletedAt *time.Time `json:"deletedAt,omitempty"` + Description ClusterDescription `json:"description"` + + // Id A unique identifier for this resource. + Id Identifier `json:"id"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + + // Items A list of items within the context of belonging to a cluster. Different + // from an ItemList because we do not need to include the parent cluster + // information inside each item since it's already available. + Items ClusterItemList `json:"items"` + + // Misc Arbitrary extra data stored with the resource. + Misc *map[string]interface{} `json:"misc,omitempty"` + Name ClusterName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ClusterSlug `json:"slug"` + + // UpdatedAt The time the resource was updated. + UpdatedAt time.Time `json:"updatedAt"` +} + // Collection defines model for Collection. type Collection struct { // CreatedAt The time the resource was created. @@ -634,6 +824,174 @@ type Info struct { Title string `json:"title"` } +// Item defines model for Item. +type Item struct { + // CreatedAt The time the resource was created. + CreatedAt time.Time `json:"createdAt"` + + // DeletedAt The time the resource was soft-deleted. + DeletedAt *time.Time `json:"deletedAt,omitempty"` + Description ItemDescription `json:"description"` + + // Id A unique identifier for this resource. + Id Identifier `json:"id"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + + // Misc Arbitrary extra data stored with the resource. + Misc *map[string]interface{} `json:"misc,omitempty"` + Name ItemName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ItemSlug `json:"slug"` + + // UpdatedAt The time the resource was updated. + UpdatedAt time.Time `json:"updatedAt"` +} + +// ItemCommonProps The main properties for an item. +type ItemCommonProps struct { + Description ItemDescription `json:"description"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name ItemName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ItemSlug `json:"slug"` +} + +// ItemDescription defines model for ItemDescription. +type ItemDescription = string + +// ItemInitialProps defines model for ItemInitialProps. +type ItemInitialProps struct { + Description ItemDescription `json:"description"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name ItemName `json:"name"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ItemSlug `json:"slug"` +} + +// ItemList A list of items where each item includes all the information about its +// parent cluster too. For use with APIs that want to provide a list of +// items that may be part of different clusters. +type ItemList = []ItemWithParents + +// ItemMutableProps Note: Properties are replace-all and are not merged with existing. +type ItemMutableProps struct { + Description *ItemDescription `json:"description,omitempty"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + Name *ItemName `json:"name,omitempty"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug *ItemSlug `json:"slug,omitempty"` +} + +// ItemName defines model for ItemName. +type ItemName = string + +// ItemSlug A URL-safe slug for uniquely identifying resources. +type ItemSlug = Slug + +// ItemWithParents defines model for ItemWithParents. +type ItemWithParents struct { + Clusters *ClusterList `json:"clusters,omitempty"` + + // CreatedAt The time the resource was created. + CreatedAt time.Time `json:"createdAt"` + + // DeletedAt The time the resource was soft-deleted. + DeletedAt *time.Time `json:"deletedAt,omitempty"` + Description ItemDescription `json:"description"` + + // Id A unique identifier for this resource. + Id Identifier `json:"id"` + + // ImageUrl The URL of an asset uploaded to the platform. + ImageUrl *AssetURL `json:"image_url,omitempty"` + + // Misc Arbitrary extra data stored with the resource. + Misc *map[string]interface{} `json:"misc,omitempty"` + Name ItemName `json:"name"` + + // Owner A minimal reference to an account. + Owner ProfileReference `json:"owner"` + + // Properties Arbitrary JSON object that can express any additional data for a + // resource object. This is intended for client implementations to use for + // extending objects with arbitrary information to satisfy product needs. + // + // For example, if you were building a book database, you could use the + // Properties of a cluster to specify publisher information such as date of + // founding, headquarters, size, etc. and then use the Properties of the + // items in that cluster to specify book information such as release date, + // number of pages, etc. + Properties *Properties `json:"properties,omitempty"` + + // Slug A URL-safe slug for uniquely identifying resources. + Slug ItemSlug `json:"slug"` + + // UpdatedAt The time the resource was updated. + UpdatedAt time.Time `json:"updatedAt"` +} + // Metadata Arbitrary metadata for the resource. type Metadata map[string]interface{} @@ -819,6 +1177,17 @@ type ProfileReference struct { Name AccountName `json:"name"` } +// Properties Arbitrary JSON object that can express any additional data for a +// resource object. This is intended for client implementations to use for +// extending objects with arbitrary information to satisfy product needs. +// +// For example, if you were building a book database, you could use the +// Properties of a cluster to specify publisher information such as date of +// founding, headquarters, size, etc. and then use the Properties of the +// items in that cluster to specify book information such as release date, +// number of pages, etc. +type Properties map[string]interface{} + // PublicKeyCredential https://www.w3.org/TR/webauthn-2/#iface-pkcredential type PublicKeyCredential struct { AuthenticatorAttachment *string `json:"authenticatorAttachment,omitempty"` @@ -943,6 +1312,9 @@ type ReactList = []React // ResidentKeyRequirement https://www.w3.org/TR/webauthn-2/#enumdef-residentkeyrequirement type ResidentKeyRequirement string +// Slug A URL-safe slug for uniquely identifying resources. +type Slug = string + // Tag A tag which can link profiles or threads via interests. type Tag struct { Colour *string `json:"colour,omitempty"` @@ -1174,6 +1546,12 @@ type AssetPath = string // CategoryIDParam A unique identifier for this resource. type CategoryIDParam = Identifier +// ClusterSlugChildParam A unique identifier for this resource. +type ClusterSlugChildParam = Identifier + +// ClusterSlugParam A unique identifier for this resource. +type ClusterSlugParam = Identifier + // CollectionIDParam A unique identifier for this resource. type CollectionIDParam = Identifier @@ -1183,6 +1561,9 @@ type ContentLength = float32 // IconSize defines model for IconSize. type IconSize string +// ItemSlugParam A unique identifier for this resource. +type ItemSlugParam = Identifier + // OAuthProvider defines model for OAuthProvider. type OAuthProvider = string @@ -1231,6 +1612,52 @@ type CategoryListOK = CategoryList // CategoryUpdateOK defines model for CategoryUpdateOK. type CategoryUpdateOK = Category +// ClusterAddChildOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterAddChildOK = Cluster + +// ClusterAddItemOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterAddItemOK = Cluster + +// ClusterCreateOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterCreateOK = Cluster + +// ClusterGetOK The full properties of a cluster including all items and maybe child +// clusters (depending on what the endpoint is configured or queried to do) +// for rendering a single cluster on a view. +type ClusterGetOK = ClusterWithItems + +// ClusterListOK defines model for ClusterListOK. +type ClusterListOK struct { + Clusters ClusterList `json:"clusters"` +} + +// ClusterRemoveChildOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterRemoveChildOK = Cluster + +// ClusterRemoveItemOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterRemoveItemOK = Cluster + +// ClusterUpdateOK A cluster is a group of items and other clusters. It serves as an +// abstraction for grouping structured data objects. It can represent +// things such as brands, manufacturers, authors, directors, etc. Clusters +// can be referenced in content posts and they also have their own content. +type ClusterUpdateOK = Cluster + // CollectionAddPostOK A collection is a group of threads owned by a user. It allows users to // curate their own lists of content from the site. Collections can only // contain root level posts (threads) with titles and slugs to link to. @@ -1267,6 +1694,40 @@ type GetInfoOK = Info // related metadata from the request and associated services. type InternalServerError = APIError +// ItemCreateOK An item is an arbitrary object used for indexing any kind of structured +// data for the purposes of archival, search, documentation, products, etc. +// Items are similar to posts in terms of data model but are semantically +// different when it comes to purpose. +// +// If you were to use Storyden to run a community for a video game for +// example, items could be used to represent actual items from the game +// which allows members to search for them as well as reference them in +// posts and other content. +type ItemCreateOK = Item + +// ItemGetOK Represents an item with the parent cluster information included. Used by +// schemas that only want a single item along with its cluster information. +type ItemGetOK = ItemWithParents + +// ItemListOK defines model for ItemListOK. +type ItemListOK struct { + // Clusters A list of items where each item includes all the information about its + // parent cluster too. For use with APIs that want to provide a list of + // items that may be part of different clusters. + Clusters ItemList `json:"clusters"` +} + +// ItemUpdateOK An item is an arbitrary object used for indexing any kind of structured +// data for the purposes of archival, search, documentation, products, etc. +// Items are similar to posts in terms of data model but are semantically +// different when it comes to purpose. +// +// If you were to use Storyden to run a community for a video game for +// example, items could be used to represent actual items from the game +// which allows members to search for them as well as reference them in +// posts and other content. +type ItemUpdateOK = Item + // PostCreateOK A new post within a thread of posts. A post may reply to another post in // the thread by specifying the `reply_to` property. The identifier in the // `reply_to` value must be post within the same thread. @@ -1324,12 +1785,24 @@ type CategoryUpdate = CategoryMutableProps // CategoryUpdateOrder defines model for CategoryUpdateOrder. type CategoryUpdateOrder = CategoryIdentifierList +// ClusterCreate defines model for ClusterCreate. +type ClusterCreate = ClusterInitialProps + +// ClusterUpdate Note: Properties are replace-all and are not merged with existing. +type ClusterUpdate = ClusterMutableProps + // CollectionCreate defines model for CollectionCreate. type CollectionCreate = CollectionInitialProps // CollectionUpdate defines model for CollectionUpdate. type CollectionUpdate = CollectionMutableProps +// ItemCreate defines model for ItemCreate. +type ItemCreate = ItemInitialProps + +// ItemUpdate Note: Properties are replace-all and are not merged with existing. +type ItemUpdate = ItemMutableProps + // OAuthProviderCallback defines model for OAuthProviderCallback. type OAuthProviderCallback = OAuthCallback @@ -1441,12 +1914,24 @@ type CategoryCreateJSONRequestBody = CategoryInitialProps // CategoryUpdateJSONRequestBody defines body for CategoryUpdate for application/json ContentType. type CategoryUpdateJSONRequestBody = CategoryMutableProps +// ClusterCreateJSONRequestBody defines body for ClusterCreate for application/json ContentType. +type ClusterCreateJSONRequestBody = ClusterInitialProps + +// ClusterUpdateJSONRequestBody defines body for ClusterUpdate for application/json ContentType. +type ClusterUpdateJSONRequestBody = ClusterMutableProps + // CollectionCreateJSONRequestBody defines body for CollectionCreate for application/json ContentType. type CollectionCreateJSONRequestBody = CollectionInitialProps // CollectionUpdateJSONRequestBody defines body for CollectionUpdate for application/json ContentType. type CollectionUpdateJSONRequestBody = CollectionMutableProps +// ItemCreateJSONRequestBody defines body for ItemCreate for application/json ContentType. +type ItemCreateJSONRequestBody = ItemInitialProps + +// ItemUpdateJSONRequestBody defines body for ItemUpdate for application/json ContentType. +type ItemUpdateJSONRequestBody = ItemMutableProps + // PostUpdateJSONRequestBody defines body for PostUpdate for application/json ContentType. type PostUpdateJSONRequestBody = PostMutableProps @@ -1631,6 +2116,34 @@ type ClientInterface interface { CategoryUpdate(ctx context.Context, categoryId CategoryIDParam, body CategoryUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ClusterList request + ClusterList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterCreate request with any body + ClusterCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ClusterCreate(ctx context.Context, body ClusterCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterGet request + ClusterGet(ctx context.Context, clusterSlug ClusterSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterUpdate request with any body + ClusterUpdateWithBody(ctx context.Context, clusterSlug ClusterSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ClusterUpdate(ctx context.Context, clusterSlug ClusterSlugParam, body ClusterUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterRemoveCluster request + ClusterRemoveCluster(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterAddCluster request + ClusterAddCluster(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterRemoveItem request + ClusterRemoveItem(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClusterAddItem request + ClusterAddItem(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) + // CollectionList request CollectionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1662,6 +2175,22 @@ type ClientInterface interface { // IconGet request IconGet(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*http.Response, error) + // ItemList request + ItemList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ItemCreate request with any body + ItemCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ItemCreate(ctx context.Context, body ItemCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ItemGet request + ItemGet(ctx context.Context, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ItemUpdate request with any body + ItemUpdateWithBody(ctx context.Context, itemSlug ItemSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ItemUpdate(ctx context.Context, itemSlug ItemSlugParam, body ItemUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostSearch request PostSearch(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2141,8 +2670,8 @@ func (c *Client) CategoryUpdate(ctx context.Context, categoryId CategoryIDParam, return c.Client.Do(req) } -func (c *Client) CollectionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionListRequest(c.Server) +func (c *Client) ClusterList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterListRequest(c.Server) if err != nil { return nil, err } @@ -2153,8 +2682,8 @@ func (c *Client) CollectionList(ctx context.Context, reqEditors ...RequestEditor return c.Client.Do(req) } -func (c *Client) CollectionCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionCreateRequestWithBody(c.Server, contentType, body) +func (c *Client) ClusterCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterCreateRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } @@ -2165,8 +2694,8 @@ func (c *Client) CollectionCreateWithBody(ctx context.Context, contentType strin return c.Client.Do(req) } -func (c *Client) CollectionCreate(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionCreateRequest(c.Server, body) +func (c *Client) ClusterCreate(ctx context.Context, body ClusterCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterCreateRequest(c.Server, body) if err != nil { return nil, err } @@ -2177,8 +2706,8 @@ func (c *Client) CollectionCreate(ctx context.Context, body CollectionCreateJSON return c.Client.Do(req) } -func (c *Client) CollectionGet(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionGetRequest(c.Server, collectionId) +func (c *Client) ClusterGet(ctx context.Context, clusterSlug ClusterSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterGetRequest(c.Server, clusterSlug) if err != nil { return nil, err } @@ -2189,8 +2718,8 @@ func (c *Client) CollectionGet(ctx context.Context, collectionId CollectionIDPar return c.Client.Do(req) } -func (c *Client) CollectionUpdateWithBody(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionUpdateRequestWithBody(c.Server, collectionId, contentType, body) +func (c *Client) ClusterUpdateWithBody(ctx context.Context, clusterSlug ClusterSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterUpdateRequestWithBody(c.Server, clusterSlug, contentType, body) if err != nil { return nil, err } @@ -2201,8 +2730,8 @@ func (c *Client) CollectionUpdateWithBody(ctx context.Context, collectionId Coll return c.Client.Do(req) } -func (c *Client) CollectionUpdate(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionUpdateRequest(c.Server, collectionId, body) +func (c *Client) ClusterUpdate(ctx context.Context, clusterSlug ClusterSlugParam, body ClusterUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterUpdateRequest(c.Server, clusterSlug, body) if err != nil { return nil, err } @@ -2213,8 +2742,8 @@ func (c *Client) CollectionUpdate(ctx context.Context, collectionId CollectionID return c.Client.Do(req) } -func (c *Client) CollectionRemovePost(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionRemovePostRequest(c.Server, collectionId, postId) +func (c *Client) ClusterRemoveCluster(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterRemoveClusterRequest(c.Server, clusterSlug, clusterSlugChild) if err != nil { return nil, err } @@ -2225,8 +2754,8 @@ func (c *Client) CollectionRemovePost(ctx context.Context, collectionId Collecti return c.Client.Do(req) } -func (c *Client) CollectionAddPost(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCollectionAddPostRequest(c.Server, collectionId, postId) +func (c *Client) ClusterAddCluster(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterAddClusterRequest(c.Server, clusterSlug, clusterSlugChild) if err != nil { return nil, err } @@ -2237,8 +2766,8 @@ func (c *Client) CollectionAddPost(ctx context.Context, collectionId CollectionI return c.Client.Do(req) } -func (c *Client) GetInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetInfoRequest(c.Server) +func (c *Client) ClusterRemoveItem(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterRemoveItemRequest(c.Server, clusterSlug, itemSlug) if err != nil { return nil, err } @@ -2249,8 +2778,8 @@ func (c *Client) GetInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*h return c.Client.Do(req) } -func (c *Client) IconUploadWithBody(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewIconUploadRequestWithBody(c.Server, params, contentType, body) +func (c *Client) ClusterAddItem(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClusterAddItemRequest(c.Server, clusterSlug, itemSlug) if err != nil { return nil, err } @@ -2261,8 +2790,8 @@ func (c *Client) IconUploadWithBody(ctx context.Context, params *IconUploadParam return c.Client.Do(req) } -func (c *Client) IconGet(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewIconGetRequest(c.Server, iconSize) +func (c *Client) CollectionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionListRequest(c.Server) if err != nil { return nil, err } @@ -2273,8 +2802,8 @@ func (c *Client) IconGet(ctx context.Context, iconSize IconGetParamsIconSize, re return c.Client.Do(req) } -func (c *Client) PostSearch(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostSearchRequest(c.Server, params) +func (c *Client) CollectionCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionCreateRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } @@ -2285,8 +2814,8 @@ func (c *Client) PostSearch(ctx context.Context, params *PostSearchParams, reqEd return c.Client.Do(req) } -func (c *Client) PostDelete(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostDeleteRequest(c.Server, postId) +func (c *Client) CollectionCreate(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionCreateRequest(c.Server, body) if err != nil { return nil, err } @@ -2297,8 +2826,8 @@ func (c *Client) PostDelete(ctx context.Context, postId PostIDParam, reqEditors return c.Client.Do(req) } -func (c *Client) PostUpdateWithBody(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostUpdateRequestWithBody(c.Server, postId, contentType, body) +func (c *Client) CollectionGet(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionGetRequest(c.Server, collectionId) if err != nil { return nil, err } @@ -2309,8 +2838,8 @@ func (c *Client) PostUpdateWithBody(ctx context.Context, postId PostIDParam, con return c.Client.Do(req) } -func (c *Client) PostUpdate(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostUpdateRequest(c.Server, postId, body) +func (c *Client) CollectionUpdateWithBody(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionUpdateRequestWithBody(c.Server, collectionId, contentType, body) if err != nil { return nil, err } @@ -2321,8 +2850,8 @@ func (c *Client) PostUpdate(ctx context.Context, postId PostIDParam, body PostUp return c.Client.Do(req) } -func (c *Client) PostReactAddWithBody(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostReactAddRequestWithBody(c.Server, postId, contentType, body) +func (c *Client) CollectionUpdate(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionUpdateRequest(c.Server, collectionId, body) if err != nil { return nil, err } @@ -2333,8 +2862,8 @@ func (c *Client) PostReactAddWithBody(ctx context.Context, postId PostIDParam, c return c.Client.Do(req) } -func (c *Client) PostReactAdd(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostReactAddRequest(c.Server, postId, body) +func (c *Client) CollectionRemovePost(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionRemovePostRequest(c.Server, collectionId, postId) if err != nil { return nil, err } @@ -2345,8 +2874,8 @@ func (c *Client) PostReactAdd(ctx context.Context, postId PostIDParam, body Post return c.Client.Do(req) } -func (c *Client) ProfileGet(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewProfileGetRequest(c.Server, accountHandle) +func (c *Client) CollectionAddPost(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCollectionAddPostRequest(c.Server, collectionId, postId) if err != nil { return nil, err } @@ -2357,8 +2886,8 @@ func (c *Client) ProfileGet(ctx context.Context, accountHandle AccountHandlePara return c.Client.Do(req) } -func (c *Client) ThreadList(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadListRequest(c.Server, params) +func (c *Client) GetInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetInfoRequest(c.Server) if err != nil { return nil, err } @@ -2369,8 +2898,8 @@ func (c *Client) ThreadList(ctx context.Context, params *ThreadListParams, reqEd return c.Client.Do(req) } -func (c *Client) ThreadCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadCreateRequestWithBody(c.Server, contentType, body) +func (c *Client) IconUploadWithBody(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIconUploadRequestWithBody(c.Server, params, contentType, body) if err != nil { return nil, err } @@ -2381,8 +2910,8 @@ func (c *Client) ThreadCreateWithBody(ctx context.Context, contentType string, b return c.Client.Do(req) } -func (c *Client) ThreadCreate(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadCreateRequest(c.Server, body) +func (c *Client) IconGet(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIconGetRequest(c.Server, iconSize) if err != nil { return nil, err } @@ -2393,8 +2922,8 @@ func (c *Client) ThreadCreate(ctx context.Context, body ThreadCreateJSONRequestB return c.Client.Do(req) } -func (c *Client) ThreadDelete(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadDeleteRequest(c.Server, threadMark) +func (c *Client) ItemList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemListRequest(c.Server) if err != nil { return nil, err } @@ -2405,8 +2934,8 @@ func (c *Client) ThreadDelete(ctx context.Context, threadMark ThreadMarkParam, r return c.Client.Do(req) } -func (c *Client) ThreadGet(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadGetRequest(c.Server, threadMark) +func (c *Client) ItemCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemCreateRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } @@ -2417,8 +2946,8 @@ func (c *Client) ThreadGet(ctx context.Context, threadMark ThreadMarkParam, reqE return c.Client.Do(req) } -func (c *Client) ThreadUpdateWithBody(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadUpdateRequestWithBody(c.Server, threadMark, contentType, body) +func (c *Client) ItemCreate(ctx context.Context, body ItemCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemCreateRequest(c.Server, body) if err != nil { return nil, err } @@ -2429,8 +2958,8 @@ func (c *Client) ThreadUpdateWithBody(ctx context.Context, threadMark ThreadMark return c.Client.Do(req) } -func (c *Client) ThreadUpdate(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewThreadUpdateRequest(c.Server, threadMark, body) +func (c *Client) ItemGet(ctx context.Context, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemGetRequest(c.Server, itemSlug) if err != nil { return nil, err } @@ -2441,8 +2970,8 @@ func (c *Client) ThreadUpdate(ctx context.Context, threadMark ThreadMarkParam, b return c.Client.Do(req) } -func (c *Client) PostCreateWithBody(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostCreateRequestWithBody(c.Server, threadMark, contentType, body) +func (c *Client) ItemUpdateWithBody(ctx context.Context, itemSlug ItemSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemUpdateRequestWithBody(c.Server, itemSlug, contentType, body) if err != nil { return nil, err } @@ -2453,8 +2982,8 @@ func (c *Client) PostCreateWithBody(ctx context.Context, threadMark ThreadMarkPa return c.Client.Do(req) } -func (c *Client) PostCreate(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostCreateRequest(c.Server, threadMark, body) +func (c *Client) ItemUpdate(ctx context.Context, itemSlug ItemSlugParam, body ItemUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewItemUpdateRequest(c.Server, itemSlug, body) if err != nil { return nil, err } @@ -2465,8 +2994,8 @@ func (c *Client) PostCreate(ctx context.Context, threadMark ThreadMarkParam, bod return c.Client.Do(req) } -func (c *Client) GetVersion(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetVersionRequest(c.Server) +func (c *Client) PostSearch(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostSearchRequest(c.Server, params) if err != nil { return nil, err } @@ -2477,8 +3006,200 @@ func (c *Client) GetVersion(ctx context.Context, reqEditors ...RequestEditorFn) return c.Client.Do(req) } -// NewGetSpecRequest generates requests for GetSpec -func NewGetSpecRequest(server string) (*http.Request, error) { +func (c *Client) PostDelete(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostDeleteRequest(c.Server, postId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostUpdateWithBody(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostUpdateRequestWithBody(c.Server, postId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostUpdate(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostUpdateRequest(c.Server, postId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostReactAddWithBody(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostReactAddRequestWithBody(c.Server, postId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostReactAdd(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostReactAddRequest(c.Server, postId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ProfileGet(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProfileGetRequest(c.Server, accountHandle) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadList(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadListRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadCreateRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadCreate(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadCreateRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadDelete(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadDeleteRequest(c.Server, threadMark) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadGet(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadGetRequest(c.Server, threadMark) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadUpdateWithBody(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadUpdateRequestWithBody(c.Server, threadMark, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ThreadUpdate(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewThreadUpdateRequest(c.Server, threadMark, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostCreateWithBody(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostCreateRequestWithBody(c.Server, threadMark, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostCreate(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostCreateRequest(c.Server, threadMark, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetVersion(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVersionRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetSpecRequest generates requests for GetSpec +func NewGetSpecRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -3352,8 +4073,8 @@ func NewCategoryUpdateRequestWithBody(server string, categoryId CategoryIDParam, return req, nil } -// NewCollectionListRequest generates requests for CollectionList -func NewCollectionListRequest(server string) (*http.Request, error) { +// NewClusterListRequest generates requests for ClusterList +func NewClusterListRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -3361,7 +4082,7 @@ func NewCollectionListRequest(server string) (*http.Request, error) { return nil, err } - operationPath := fmt.Sprintf("/v1/collections") + operationPath := fmt.Sprintf("/v1/clusters") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3379,19 +4100,19 @@ func NewCollectionListRequest(server string) (*http.Request, error) { return req, nil } -// NewCollectionCreateRequest calls the generic CollectionCreate builder with application/json body -func NewCollectionCreateRequest(server string, body CollectionCreateJSONRequestBody) (*http.Request, error) { +// NewClusterCreateRequest calls the generic ClusterCreate builder with application/json body +func NewClusterCreateRequest(server string, body ClusterCreateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCollectionCreateRequestWithBody(server, "application/json", bodyReader) + return NewClusterCreateRequestWithBody(server, "application/json", bodyReader) } -// NewCollectionCreateRequestWithBody generates requests for CollectionCreate with any type of body -func NewCollectionCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { +// NewClusterCreateRequestWithBody generates requests for ClusterCreate with any type of body +func NewClusterCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -3399,7 +4120,7 @@ func NewCollectionCreateRequestWithBody(server string, contentType string, body return nil, err } - operationPath := fmt.Sprintf("/v1/collections") + operationPath := fmt.Sprintf("/v1/clusters") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3419,13 +4140,13 @@ func NewCollectionCreateRequestWithBody(server string, contentType string, body return req, nil } -// NewCollectionGetRequest generates requests for CollectionGet -func NewCollectionGetRequest(server string, collectionId CollectionIDParam) (*http.Request, error) { +// NewClusterGetRequest generates requests for ClusterGet +func NewClusterGetRequest(server string, clusterSlug ClusterSlugParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) if err != nil { return nil, err } @@ -3435,7 +4156,7 @@ func NewCollectionGetRequest(server string, collectionId CollectionIDParam) (*ht return nil, err } - operationPath := fmt.Sprintf("/v1/collections/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/clusters/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3453,24 +4174,24 @@ func NewCollectionGetRequest(server string, collectionId CollectionIDParam) (*ht return req, nil } -// NewCollectionUpdateRequest calls the generic CollectionUpdate builder with application/json body -func NewCollectionUpdateRequest(server string, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody) (*http.Request, error) { +// NewClusterUpdateRequest calls the generic ClusterUpdate builder with application/json body +func NewClusterUpdateRequest(server string, clusterSlug ClusterSlugParam, body ClusterUpdateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCollectionUpdateRequestWithBody(server, collectionId, "application/json", bodyReader) + return NewClusterUpdateRequestWithBody(server, clusterSlug, "application/json", bodyReader) } -// NewCollectionUpdateRequestWithBody generates requests for CollectionUpdate with any type of body -func NewCollectionUpdateRequestWithBody(server string, collectionId CollectionIDParam, contentType string, body io.Reader) (*http.Request, error) { +// NewClusterUpdateRequestWithBody generates requests for ClusterUpdate with any type of body +func NewClusterUpdateRequestWithBody(server string, clusterSlug ClusterSlugParam, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) if err != nil { return nil, err } @@ -3480,7 +4201,7 @@ func NewCollectionUpdateRequestWithBody(server string, collectionId CollectionID return nil, err } - operationPath := fmt.Sprintf("/v1/collections/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/clusters/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3500,20 +4221,20 @@ func NewCollectionUpdateRequestWithBody(server string, collectionId CollectionID return req, nil } -// NewCollectionRemovePostRequest generates requests for CollectionRemovePost -func NewCollectionRemovePostRequest(server string, collectionId CollectionIDParam, postId PostIDParam) (*http.Request, error) { +// NewClusterRemoveClusterRequest generates requests for ClusterRemoveCluster +func NewClusterRemoveClusterRequest(server string, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) if err != nil { return nil, err } var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug_child", runtime.ParamLocationPath, clusterSlugChild) if err != nil { return nil, err } @@ -3523,7 +4244,7 @@ func NewCollectionRemovePostRequest(server string, collectionId CollectionIDPara return nil, err } - operationPath := fmt.Sprintf("/v1/collections/%s/items/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/v1/clusters/%s/clusters/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3541,20 +4262,20 @@ func NewCollectionRemovePostRequest(server string, collectionId CollectionIDPara return req, nil } -// NewCollectionAddPostRequest generates requests for CollectionAddPost -func NewCollectionAddPostRequest(server string, collectionId CollectionIDParam, postId PostIDParam) (*http.Request, error) { +// NewClusterAddClusterRequest generates requests for ClusterAddCluster +func NewClusterAddClusterRequest(server string, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) if err != nil { return nil, err } var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug_child", runtime.ParamLocationPath, clusterSlugChild) if err != nil { return nil, err } @@ -3564,7 +4285,7 @@ func NewCollectionAddPostRequest(server string, collectionId CollectionIDParam, return nil, err } - operationPath := fmt.Sprintf("/v1/collections/%s/items/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/v1/clusters/%s/clusters/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3582,16 +4303,30 @@ func NewCollectionAddPostRequest(server string, collectionId CollectionIDParam, return req, nil } -// NewGetInfoRequest generates requests for GetInfo -func NewGetInfoRequest(server string) (*http.Request, error) { +// NewClusterRemoveItemRequest generates requests for ClusterRemoveItem +func NewClusterRemoveItemRequest(server string, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, itemSlug) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/v1/info") + operationPath := fmt.Sprintf("/v1/clusters/%s/items/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3601,7 +4336,7 @@ func NewGetInfoRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } @@ -3609,16 +4344,30 @@ func NewGetInfoRequest(server string) (*http.Request, error) { return req, nil } -// NewIconUploadRequestWithBody generates requests for IconUpload with any type of body -func NewIconUploadRequestWithBody(server string, params *IconUploadParams, contentType string, body io.Reader) (*http.Request, error) { +// NewClusterAddItemRequest generates requests for ClusterAddItem +func NewClusterAddItemRequest(server string, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, clusterSlug) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, itemSlug) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/v1/info/icon") + operationPath := fmt.Sprintf("/v1/clusters/%s/items/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3628,42 +4377,24 @@ func NewIconUploadRequestWithBody(server string, params *IconUploadParams, conte return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, params.ContentLength) + req, err := http.NewRequest("PUT", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Set("Content-Length", headerParam0) - return req, nil } -// NewIconGetRequest generates requests for IconGet -func NewIconGetRequest(server string, iconSize IconGetParamsIconSize) (*http.Request, error) { +// NewCollectionListRequest generates requests for CollectionList +func NewCollectionListRequest(server string) (*http.Request, error) { var err error - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "icon_size", runtime.ParamLocationPath, iconSize) - if err != nil { - return nil, err - } - serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/v1/info/icon/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/collections") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3681,8 +4412,19 @@ func NewIconGetRequest(server string, iconSize IconGetParamsIconSize) (*http.Req return req, nil } -// NewPostSearchRequest generates requests for PostSearch -func NewPostSearchRequest(server string, params *PostSearchParams) (*http.Request, error) { +// NewCollectionCreateRequest calls the generic CollectionCreate builder with application/json body +func NewCollectionCreateRequest(server string, body CollectionCreateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCollectionCreateRequestWithBody(server, "application/json", bodyReader) +} + +// NewCollectionCreateRequestWithBody generates requests for CollectionCreate with any type of body +func NewCollectionCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -3690,7 +4432,7 @@ func NewPostSearchRequest(server string, params *PostSearchParams) (*http.Reques return nil, err } - operationPath := fmt.Sprintf("/v1/posts/search") + operationPath := fmt.Sprintf("/v1/collections") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3700,73 +4442,23 @@ func NewPostSearchRequest(server string, params *PostSearchParams) (*http.Reques return nil, err } - queryValues := queryURL.Query() - - if params.Body != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "body", runtime.ParamLocationQuery, *params.Body); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Author != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "author", runtime.ParamLocationQuery, *params.Author); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Kind != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "kind", runtime.ParamLocationQuery, *params.Kind); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } + req.Header.Add("Content-Type", contentType) + return req, nil } -// NewPostDeleteRequest generates requests for PostDelete -func NewPostDeleteRequest(server string, postId PostIDParam) (*http.Request, error) { +// NewCollectionGetRequest generates requests for CollectionGet +func NewCollectionGetRequest(server string, collectionId CollectionIDParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) if err != nil { return nil, err } @@ -3776,7 +4468,7 @@ func NewPostDeleteRequest(server string, postId PostIDParam) (*http.Request, err return nil, err } - operationPath := fmt.Sprintf("/v1/posts/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/collections/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3786,7 +4478,7 @@ func NewPostDeleteRequest(server string, postId PostIDParam) (*http.Request, err return nil, err } - req, err := http.NewRequest("DELETE", queryURL.String(), nil) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } @@ -3794,24 +4486,24 @@ func NewPostDeleteRequest(server string, postId PostIDParam) (*http.Request, err return req, nil } -// NewPostUpdateRequest calls the generic PostUpdate builder with application/json body -func NewPostUpdateRequest(server string, postId PostIDParam, body PostUpdateJSONRequestBody) (*http.Request, error) { +// NewCollectionUpdateRequest calls the generic CollectionUpdate builder with application/json body +func NewCollectionUpdateRequest(server string, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewPostUpdateRequestWithBody(server, postId, "application/json", bodyReader) + return NewCollectionUpdateRequestWithBody(server, collectionId, "application/json", bodyReader) } -// NewPostUpdateRequestWithBody generates requests for PostUpdate with any type of body -func NewPostUpdateRequestWithBody(server string, postId PostIDParam, contentType string, body io.Reader) (*http.Request, error) { +// NewCollectionUpdateRequestWithBody generates requests for CollectionUpdate with any type of body +func NewCollectionUpdateRequestWithBody(server string, collectionId CollectionIDParam, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) if err != nil { return nil, err } @@ -3821,7 +4513,7 @@ func NewPostUpdateRequestWithBody(server string, postId PostIDParam, contentType return nil, err } - operationPath := fmt.Sprintf("/v1/posts/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/collections/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3841,24 +4533,20 @@ func NewPostUpdateRequestWithBody(server string, postId PostIDParam, contentType return req, nil } -// NewPostReactAddRequest calls the generic PostReactAdd builder with application/json body -func NewPostReactAddRequest(server string, postId PostIDParam, body PostReactAddJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) +// NewCollectionRemovePostRequest generates requests for CollectionRemovePost +func NewCollectionRemovePostRequest(server string, collectionId CollectionIDParam, postId PostIDParam) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewPostReactAddRequestWithBody(server, postId, "application/json", bodyReader) -} - -// NewPostReactAddRequestWithBody generates requests for PostReactAdd with any type of body -func NewPostReactAddRequestWithBody(server string, postId PostIDParam, contentType string, body io.Reader) (*http.Request, error) { - var err error - var pathParam0 string + var pathParam1 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) if err != nil { return nil, err } @@ -3868,7 +4556,7 @@ func NewPostReactAddRequestWithBody(server string, postId PostIDParam, contentTy return nil, err } - operationPath := fmt.Sprintf("/v1/posts/%s/reacts", pathParam0) + operationPath := fmt.Sprintf("/v1/collections/%s/items/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3878,23 +4566,28 @@ func NewPostReactAddRequestWithBody(server string, postId PostIDParam, contentTy return nil, err } - req, err := http.NewRequest("PUT", queryURL.String(), body) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Add("Content-Type", contentType) - return req, nil } -// NewProfileGetRequest generates requests for ProfileGet -func NewProfileGetRequest(server string, accountHandle AccountHandleParam) (*http.Request, error) { +// NewCollectionAddPostRequest generates requests for CollectionAddPost +func NewCollectionAddPostRequest(server string, collectionId CollectionIDParam, postId PostIDParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, accountHandle) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, collectionId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) if err != nil { return nil, err } @@ -3904,7 +4597,7 @@ func NewProfileGetRequest(server string, accountHandle AccountHandleParam) (*htt return nil, err } - operationPath := fmt.Sprintf("/v1/profiles/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/collections/%s/items/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3914,7 +4607,7 @@ func NewProfileGetRequest(server string, accountHandle AccountHandleParam) (*htt return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("PUT", queryURL.String(), nil) if err != nil { return nil, err } @@ -3922,8 +4615,8 @@ func NewProfileGetRequest(server string, accountHandle AccountHandleParam) (*htt return req, nil } -// NewThreadListRequest generates requests for ThreadList -func NewThreadListRequest(server string, params *ThreadListParams) (*http.Request, error) { +// NewGetInfoRequest generates requests for GetInfo +func NewGetInfoRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -3931,7 +4624,7 @@ func NewThreadListRequest(server string, params *ThreadListParams) (*http.Reques return nil, err } - operationPath := fmt.Sprintf("/v1/threads") + operationPath := fmt.Sprintf("/v1/info") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -3941,58 +4634,6 @@ func NewThreadListRequest(server string, params *ThreadListParams) (*http.Reques return nil, err } - queryValues := queryURL.Query() - - if params.Author != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "author", runtime.ParamLocationQuery, *params.Author); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Tags != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tags", runtime.ParamLocationQuery, *params.Tags); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Categories != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "categories", runtime.ParamLocationQuery, *params.Categories); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -4001,19 +4642,8 @@ func NewThreadListRequest(server string, params *ThreadListParams) (*http.Reques return req, nil } -// NewThreadCreateRequest calls the generic ThreadCreate builder with application/json body -func NewThreadCreateRequest(server string, body ThreadCreateJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewThreadCreateRequestWithBody(server, "application/json", bodyReader) -} - -// NewThreadCreateRequestWithBody generates requests for ThreadCreate with any type of body -func NewThreadCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { +// NewIconUploadRequestWithBody generates requests for IconUpload with any type of body +func NewIconUploadRequestWithBody(server string, params *IconUploadParams, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -4021,7 +4651,7 @@ func NewThreadCreateRequestWithBody(server string, contentType string, body io.R return nil, err } - operationPath := fmt.Sprintf("/v1/threads") + operationPath := fmt.Sprintf("/v1/info/icon") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4038,16 +4668,25 @@ func NewThreadCreateRequestWithBody(server string, contentType string, body io.R req.Header.Add("Content-Type", contentType) + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, params.ContentLength) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Length", headerParam0) + return req, nil } -// NewThreadDeleteRequest generates requests for ThreadDelete -func NewThreadDeleteRequest(server string, threadMark ThreadMarkParam) (*http.Request, error) { +// NewIconGetRequest generates requests for IconGet +func NewIconGetRequest(server string, iconSize IconGetParamsIconSize) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "icon_size", runtime.ParamLocationPath, iconSize) if err != nil { return nil, err } @@ -4057,7 +4696,7 @@ func NewThreadDeleteRequest(server string, threadMark ThreadMarkParam) (*http.Re return nil, err } - operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/info/icon/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4067,7 +4706,7 @@ func NewThreadDeleteRequest(server string, threadMark ThreadMarkParam) (*http.Re return nil, err } - req, err := http.NewRequest("DELETE", queryURL.String(), nil) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } @@ -4075,23 +4714,16 @@ func NewThreadDeleteRequest(server string, threadMark ThreadMarkParam) (*http.Re return req, nil } -// NewThreadGetRequest generates requests for ThreadGet -func NewThreadGetRequest(server string, threadMark ThreadMarkParam) (*http.Request, error) { +// NewItemListRequest generates requests for ItemList +func NewItemListRequest(server string) (*http.Request, error) { var err error - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) - if err != nil { - return nil, err - } - serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/items") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4109,24 +4741,53 @@ func NewThreadGetRequest(server string, threadMark ThreadMarkParam) (*http.Reque return req, nil } -// NewThreadUpdateRequest calls the generic ThreadUpdate builder with application/json body -func NewThreadUpdateRequest(server string, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody) (*http.Request, error) { +// NewItemCreateRequest calls the generic ItemCreate builder with application/json body +func NewItemCreateRequest(server string, body ItemCreateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewThreadUpdateRequestWithBody(server, threadMark, "application/json", bodyReader) + return NewItemCreateRequestWithBody(server, "application/json", bodyReader) } -// NewThreadUpdateRequestWithBody generates requests for ThreadUpdate with any type of body -func NewThreadUpdateRequestWithBody(server string, threadMark ThreadMarkParam, contentType string, body io.Reader) (*http.Request, error) { +// NewItemCreateRequestWithBody generates requests for ItemCreate with any type of body +func NewItemCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/items") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewItemGetRequest generates requests for ItemGet +func NewItemGetRequest(server string, itemSlug ItemSlugParam) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, itemSlug) if err != nil { return nil, err } @@ -4136,7 +4797,7 @@ func NewThreadUpdateRequestWithBody(server string, threadMark ThreadMarkParam, c return nil, err } - operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + operationPath := fmt.Sprintf("/v1/items/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4146,34 +4807,32 @@ func NewThreadUpdateRequestWithBody(server string, threadMark ThreadMarkParam, c return nil, err } - req, err := http.NewRequest("PATCH", queryURL.String(), body) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Add("Content-Type", contentType) - return req, nil } -// NewPostCreateRequest calls the generic PostCreate builder with application/json body -func NewPostCreateRequest(server string, threadMark ThreadMarkParam, body PostCreateJSONRequestBody) (*http.Request, error) { +// NewItemUpdateRequest calls the generic ItemUpdate builder with application/json body +func NewItemUpdateRequest(server string, itemSlug ItemSlugParam, body ItemUpdateJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewPostCreateRequestWithBody(server, threadMark, "application/json", bodyReader) + return NewItemUpdateRequestWithBody(server, itemSlug, "application/json", bodyReader) } -// NewPostCreateRequestWithBody generates requests for PostCreate with any type of body -func NewPostCreateRequestWithBody(server string, threadMark ThreadMarkParam, contentType string, body io.Reader) (*http.Request, error) { +// NewItemUpdateRequestWithBody generates requests for ItemUpdate with any type of body +func NewItemUpdateRequestWithBody(server string, itemSlug ItemSlugParam, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, itemSlug) if err != nil { return nil, err } @@ -4183,7 +4842,7 @@ func NewPostCreateRequestWithBody(server string, threadMark ThreadMarkParam, con return nil, err } - operationPath := fmt.Sprintf("/v1/threads/%s/posts", pathParam0) + operationPath := fmt.Sprintf("/v1/items/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4193,7 +4852,7 @@ func NewPostCreateRequestWithBody(server string, threadMark ThreadMarkParam, con return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest("PATCH", queryURL.String(), body) if err != nil { return nil, err } @@ -4203,8 +4862,8 @@ func NewPostCreateRequestWithBody(server string, threadMark ThreadMarkParam, con return req, nil } -// NewGetVersionRequest generates requests for GetVersion -func NewGetVersionRequest(server string) (*http.Request, error) { +// NewPostSearchRequest generates requests for PostSearch +func NewPostSearchRequest(server string, params *PostSearchParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -4212,7 +4871,7 @@ func NewGetVersionRequest(server string) (*http.Request, error) { return nil, err } - operationPath := fmt.Sprintf("/version") + operationPath := fmt.Sprintf("/v1/posts/search") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4222,489 +4881,1657 @@ func NewGetVersionRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err + queryValues := queryURL.Query() + + if params.Body != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "body", runtime.ParamLocationQuery, *params.Body); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + } - return req, nil -} + if params.Author != nil { -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "author", runtime.ParamLocationQuery, *params.Author); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } } + } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err + + if params.Kind != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "kind", runtime.ParamLocationQuery, *params.Kind); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } } + } - return nil -} -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} + queryURL.RawQuery = queryValues.Encode() -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } - return &ClientWithResponses{client}, nil -} -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil - } + return req, nil } -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // GetSpec request - GetSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetSpecResponse, error) +// NewPostDeleteRequest generates requests for PostDelete +func NewPostDeleteRequest(server string, postId PostIDParam) (*http.Request, error) { + var err error - // AccountGet request - AccountGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountGetResponse, error) + var pathParam0 string - // AccountUpdate request with any body - AccountUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + if err != nil { + return nil, err + } - AccountUpdateWithResponse(ctx context.Context, body AccountUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // AccountAuthProviderList request - AccountAuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountAuthProviderListResponse, error) + operationPath := fmt.Sprintf("/v1/posts/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // AccountSetAvatar request with any body - AccountSetAvatarWithBodyWithResponse(ctx context.Context, params *AccountSetAvatarParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountSetAvatarResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // AccountGetAvatar request - AccountGetAvatarWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*AccountGetAvatarResponse, error) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } - // AdminSettingsUpdate request with any body - AdminSettingsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) + return req, nil +} - AdminSettingsUpdateWithResponse(ctx context.Context, body AdminSettingsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) +// NewPostUpdateRequest calls the generic PostUpdate builder with application/json body +func NewPostUpdateRequest(server string, postId PostIDParam, body PostUpdateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostUpdateRequestWithBody(server, postId, "application/json", bodyReader) +} - // AssetUpload request with any body - AssetUploadWithBodyWithResponse(ctx context.Context, params *AssetUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AssetUploadResponse, error) +// NewPostUpdateRequestWithBody generates requests for PostUpdate with any type of body +func NewPostUpdateRequestWithBody(server string, postId PostIDParam, contentType string, body io.Reader) (*http.Request, error) { + var err error - // AssetGet request - AssetGetWithResponse(ctx context.Context, id AssetPath, reqEditors ...RequestEditorFn) (*AssetGetResponse, error) + var pathParam0 string - // AuthProviderList request - AuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderListResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + if err != nil { + return nil, err + } - // AuthProviderLogout request - AuthProviderLogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderLogoutResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // OAuthProviderCallback request with any body - OAuthProviderCallbackWithBodyWithResponse(ctx context.Context, oauthProvider OAuthProvider, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) + operationPath := fmt.Sprintf("/v1/posts/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - OAuthProviderCallbackWithResponse(ctx context.Context, oauthProvider OAuthProvider, body OAuthProviderCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // AuthPasswordSignin request with any body - AuthPasswordSigninWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } - AuthPasswordSigninWithResponse(ctx context.Context, body AuthPasswordSigninJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) + req.Header.Add("Content-Type", contentType) - // AuthPasswordSignup request with any body - AuthPasswordSignupWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) + return req, nil +} - AuthPasswordSignupWithResponse(ctx context.Context, body AuthPasswordSignupJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) +// NewPostReactAddRequest calls the generic PostReactAdd builder with application/json body +func NewPostReactAddRequest(server string, postId PostIDParam, body PostReactAddJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostReactAddRequestWithBody(server, postId, "application/json", bodyReader) +} - // PhoneRequestCode request with any body - PhoneRequestCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) - - PhoneRequestCodeWithResponse(ctx context.Context, body PhoneRequestCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) +// NewPostReactAddRequestWithBody generates requests for PostReactAdd with any type of body +func NewPostReactAddRequestWithBody(server string, postId PostIDParam, contentType string, body io.Reader) (*http.Request, error) { + var err error - // PhoneSubmitCode request with any body - PhoneSubmitCodeWithBodyWithResponse(ctx context.Context, accountHandle AccountHandleParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) + var pathParam0 string - PhoneSubmitCodeWithResponse(ctx context.Context, accountHandle AccountHandleParam, body PhoneSubmitCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "post_id", runtime.ParamLocationPath, postId) + if err != nil { + return nil, err + } - // WebAuthnMakeAssertion request with any body - WebAuthnMakeAssertionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - WebAuthnMakeAssertionWithResponse(ctx context.Context, body WebAuthnMakeAssertionJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) + operationPath := fmt.Sprintf("/v1/posts/%s/reacts", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // WebAuthnGetAssertion request - WebAuthnGetAssertionWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnGetAssertionResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // WebAuthnMakeCredential request with any body - WebAuthnMakeCredentialWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } - WebAuthnMakeCredentialWithResponse(ctx context.Context, body WebAuthnMakeCredentialJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) + req.Header.Add("Content-Type", contentType) - // WebAuthnRequestCredential request - WebAuthnRequestCredentialWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnRequestCredentialResponse, error) + return req, nil +} - // CategoryList request - CategoryListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CategoryListResponse, error) +// NewProfileGetRequest generates requests for ProfileGet +func NewProfileGetRequest(server string, accountHandle AccountHandleParam) (*http.Request, error) { + var err error - // CategoryUpdateOrder request with any body - CategoryUpdateOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) + var pathParam0 string - CategoryUpdateOrderWithResponse(ctx context.Context, body CategoryUpdateOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, accountHandle) + if err != nil { + return nil, err + } - // CategoryCreate request with any body - CategoryCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - CategoryCreateWithResponse(ctx context.Context, body CategoryCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) + operationPath := fmt.Sprintf("/v1/profiles/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // CategoryUpdate request with any body - CategoryUpdateWithBodyWithResponse(ctx context.Context, categoryId CategoryIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - CategoryUpdateWithResponse(ctx context.Context, categoryId CategoryIDParam, body CategoryUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - // CollectionList request - CollectionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CollectionListResponse, error) + return req, nil +} - // CollectionCreate request with any body - CollectionCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) +// NewThreadListRequest generates requests for ThreadList +func NewThreadListRequest(server string, params *ThreadListParams) (*http.Request, error) { + var err error - CollectionCreateWithResponse(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // CollectionGet request - CollectionGetWithResponse(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*CollectionGetResponse, error) + operationPath := fmt.Sprintf("/v1/threads") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // CollectionUpdate request with any body - CollectionUpdateWithBodyWithResponse(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - CollectionUpdateWithResponse(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) + queryValues := queryURL.Query() - // CollectionRemovePost request - CollectionRemovePostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionRemovePostResponse, error) + if params.Author != nil { - // CollectionAddPost request - CollectionAddPostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionAddPostResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "author", runtime.ParamLocationQuery, *params.Author); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // GetInfo request - GetInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetInfoResponse, error) + } - // IconUpload request with any body - IconUploadWithBodyWithResponse(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IconUploadResponse, error) + if params.Tags != nil { - // IconGet request - IconGetWithResponse(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*IconGetResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tags", runtime.ParamLocationQuery, *params.Tags); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // PostSearch request - PostSearchWithResponse(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*PostSearchResponse, error) + } - // PostDelete request - PostDeleteWithResponse(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*PostDeleteResponse, error) + if params.Categories != nil { - // PostUpdate request with any body - PostUpdateWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "categories", runtime.ParamLocationQuery, *params.Categories); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - PostUpdateWithResponse(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) + } - // PostReactAdd request with any body - PostReactAddWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) + queryURL.RawQuery = queryValues.Encode() - PostReactAddWithResponse(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - // ProfileGet request - ProfileGetWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*ProfileGetResponse, error) + return req, nil +} - // ThreadList request - ThreadListWithResponse(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*ThreadListResponse, error) +// NewThreadCreateRequest calls the generic ThreadCreate builder with application/json body +func NewThreadCreateRequest(server string, body ThreadCreateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewThreadCreateRequestWithBody(server, "application/json", bodyReader) +} - // ThreadCreate request with any body - ThreadCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) +// NewThreadCreateRequestWithBody generates requests for ThreadCreate with any type of body +func NewThreadCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error - ThreadCreateWithResponse(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // ThreadDelete request - ThreadDeleteWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadDeleteResponse, error) + operationPath := fmt.Sprintf("/v1/threads") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // ThreadGet request - ThreadGetWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadGetResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // ThreadUpdate request with any body - ThreadUpdateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } - ThreadUpdateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) + req.Header.Add("Content-Type", contentType) - // PostCreate request with any body - PostCreateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) + return req, nil +} - PostCreateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) +// NewThreadDeleteRequest generates requests for ThreadDelete +func NewThreadDeleteRequest(server string, threadMark ThreadMarkParam) (*http.Request, error) { + var err error - // GetVersion request - GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) -} + var pathParam0 string -type GetSpecResponse struct { - Body []byte - HTTPResponse *http.Response -} + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + if err != nil { + return nil, err + } -// Status returns HTTPResponse.Status -func (r GetSpecResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetSpecResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - return 0 -} -type AccountGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Account - JSONDefault *APIError -} - -// Status returns HTTPResponse.Status -func (r AccountGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AccountGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err } - return 0 -} -type AccountUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Account - JSONDefault *APIError + return req, nil } -// Status returns HTTPResponse.Status -func (r AccountUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// NewThreadGetRequest generates requests for ThreadGet +func NewThreadGetRequest(server string, threadMark ThreadMarkParam) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AccountUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type AccountAuthProviderListResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *AccountAuthMethods - JSONDefault *APIError -} + operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// Status returns HTTPResponse.Status -func (r AccountAuthProviderListResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AccountAuthProviderListResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err } - return 0 -} -type AccountSetAvatarResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError + return req, nil } -// Status returns HTTPResponse.Status -func (r AccountSetAvatarResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// NewThreadUpdateRequest calls the generic ThreadUpdate builder with application/json body +func NewThreadUpdateRequest(server string, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return http.StatusText(0) + bodyReader = bytes.NewReader(buf) + return NewThreadUpdateRequestWithBody(server, threadMark, "application/json", bodyReader) } -// StatusCode returns HTTPResponse.StatusCode -func (r AccountSetAvatarResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} +// NewThreadUpdateRequestWithBody generates requests for ThreadUpdate with any type of body +func NewThreadUpdateRequestWithBody(server string, threadMark ThreadMarkParam, contentType string, body io.Reader) (*http.Request, error) { + var err error -type AccountGetAvatarResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError -} + var pathParam0 string -// Status returns HTTPResponse.Status -func (r AccountGetAvatarResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AccountGetAvatarResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type AdminSettingsUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *AdminSettingsProps - JSONDefault *APIError -} + operationPath := fmt.Sprintf("/v1/threads/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// Status returns HTTPResponse.Status -func (r AdminSettingsUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AdminSettingsUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err } - return 0 -} -type AssetUploadResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Asset - JSONDefault *APIError -} + req.Header.Add("Content-Type", contentType) -// Status returns HTTPResponse.Status -func (r AssetUploadResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) + return req, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r AssetUploadResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// NewPostCreateRequest calls the generic PostCreate builder with application/json body +func NewPostCreateRequest(server string, threadMark ThreadMarkParam, body PostCreateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return 0 + bodyReader = bytes.NewReader(buf) + return NewPostCreateRequestWithBody(server, threadMark, "application/json", bodyReader) } -type AssetGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError -} +// NewPostCreateRequestWithBody generates requests for PostCreate with any type of body +func NewPostCreateRequestWithBody(server string, threadMark ThreadMarkParam, contentType string, body io.Reader) (*http.Request, error) { + var err error -// Status returns HTTPResponse.Status -func (r AssetGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, threadMark) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AssetGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type AuthProviderListResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Providers AuthProviderList `json:"providers"` + operationPath := fmt.Sprintf("/v1/threads/%s/posts", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - JSONDefault *APIError -} -// Status returns HTTPResponse.Status -func (r AuthProviderListResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r AuthProviderListResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err } - return 0 -} -type AuthProviderLogoutResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError + req.Header.Add("Content-Type", contentType) + + return req, nil } -// Status returns HTTPResponse.Status -func (r AuthProviderLogoutResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } +// NewGetVersionRequest generates requests for GetVersion +func NewGetVersionRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/version") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetSpec request + GetSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetSpecResponse, error) + + // AccountGet request + AccountGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountGetResponse, error) + + // AccountUpdate request with any body + AccountUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) + + AccountUpdateWithResponse(ctx context.Context, body AccountUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) + + // AccountAuthProviderList request + AccountAuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountAuthProviderListResponse, error) + + // AccountSetAvatar request with any body + AccountSetAvatarWithBodyWithResponse(ctx context.Context, params *AccountSetAvatarParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountSetAvatarResponse, error) + + // AccountGetAvatar request + AccountGetAvatarWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*AccountGetAvatarResponse, error) + + // AdminSettingsUpdate request with any body + AdminSettingsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) + + AdminSettingsUpdateWithResponse(ctx context.Context, body AdminSettingsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) + + // AssetUpload request with any body + AssetUploadWithBodyWithResponse(ctx context.Context, params *AssetUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AssetUploadResponse, error) + + // AssetGet request + AssetGetWithResponse(ctx context.Context, id AssetPath, reqEditors ...RequestEditorFn) (*AssetGetResponse, error) + + // AuthProviderList request + AuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderListResponse, error) + + // AuthProviderLogout request + AuthProviderLogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderLogoutResponse, error) + + // OAuthProviderCallback request with any body + OAuthProviderCallbackWithBodyWithResponse(ctx context.Context, oauthProvider OAuthProvider, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) + + OAuthProviderCallbackWithResponse(ctx context.Context, oauthProvider OAuthProvider, body OAuthProviderCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) + + // AuthPasswordSignin request with any body + AuthPasswordSigninWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) + + AuthPasswordSigninWithResponse(ctx context.Context, body AuthPasswordSigninJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) + + // AuthPasswordSignup request with any body + AuthPasswordSignupWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) + + AuthPasswordSignupWithResponse(ctx context.Context, body AuthPasswordSignupJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) + + // PhoneRequestCode request with any body + PhoneRequestCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) + + PhoneRequestCodeWithResponse(ctx context.Context, body PhoneRequestCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) + + // PhoneSubmitCode request with any body + PhoneSubmitCodeWithBodyWithResponse(ctx context.Context, accountHandle AccountHandleParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) + + PhoneSubmitCodeWithResponse(ctx context.Context, accountHandle AccountHandleParam, body PhoneSubmitCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) + + // WebAuthnMakeAssertion request with any body + WebAuthnMakeAssertionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) + + WebAuthnMakeAssertionWithResponse(ctx context.Context, body WebAuthnMakeAssertionJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) + + // WebAuthnGetAssertion request + WebAuthnGetAssertionWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnGetAssertionResponse, error) + + // WebAuthnMakeCredential request with any body + WebAuthnMakeCredentialWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) + + WebAuthnMakeCredentialWithResponse(ctx context.Context, body WebAuthnMakeCredentialJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) + + // WebAuthnRequestCredential request + WebAuthnRequestCredentialWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnRequestCredentialResponse, error) + + // CategoryList request + CategoryListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CategoryListResponse, error) + + // CategoryUpdateOrder request with any body + CategoryUpdateOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) + + CategoryUpdateOrderWithResponse(ctx context.Context, body CategoryUpdateOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) + + // CategoryCreate request with any body + CategoryCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) + + CategoryCreateWithResponse(ctx context.Context, body CategoryCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) + + // CategoryUpdate request with any body + CategoryUpdateWithBodyWithResponse(ctx context.Context, categoryId CategoryIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) + + CategoryUpdateWithResponse(ctx context.Context, categoryId CategoryIDParam, body CategoryUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) + + // ClusterList request + ClusterListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ClusterListResponse, error) + + // ClusterCreate request with any body + ClusterCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClusterCreateResponse, error) + + ClusterCreateWithResponse(ctx context.Context, body ClusterCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClusterCreateResponse, error) + + // ClusterGet request + ClusterGetWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, reqEditors ...RequestEditorFn) (*ClusterGetResponse, error) + + // ClusterUpdate request with any body + ClusterUpdateWithBodyWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClusterUpdateResponse, error) + + ClusterUpdateWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, body ClusterUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClusterUpdateResponse, error) + + // ClusterRemoveCluster request + ClusterRemoveClusterWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*ClusterRemoveClusterResponse, error) + + // ClusterAddCluster request + ClusterAddClusterWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*ClusterAddClusterResponse, error) + + // ClusterRemoveItem request + ClusterRemoveItemWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ClusterRemoveItemResponse, error) + + // ClusterAddItem request + ClusterAddItemWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ClusterAddItemResponse, error) + + // CollectionList request + CollectionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CollectionListResponse, error) + + // CollectionCreate request with any body + CollectionCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) + + CollectionCreateWithResponse(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) + + // CollectionGet request + CollectionGetWithResponse(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*CollectionGetResponse, error) + + // CollectionUpdate request with any body + CollectionUpdateWithBodyWithResponse(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) + + CollectionUpdateWithResponse(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) + + // CollectionRemovePost request + CollectionRemovePostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionRemovePostResponse, error) + + // CollectionAddPost request + CollectionAddPostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionAddPostResponse, error) + + // GetInfo request + GetInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetInfoResponse, error) + + // IconUpload request with any body + IconUploadWithBodyWithResponse(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IconUploadResponse, error) + + // IconGet request + IconGetWithResponse(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*IconGetResponse, error) + + // ItemList request + ItemListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ItemListResponse, error) + + // ItemCreate request with any body + ItemCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemCreateResponse, error) + + ItemCreateWithResponse(ctx context.Context, body ItemCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemCreateResponse, error) + + // ItemGet request + ItemGetWithResponse(ctx context.Context, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ItemGetResponse, error) + + // ItemUpdate request with any body + ItemUpdateWithBodyWithResponse(ctx context.Context, itemSlug ItemSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemUpdateResponse, error) + + ItemUpdateWithResponse(ctx context.Context, itemSlug ItemSlugParam, body ItemUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemUpdateResponse, error) + + // PostSearch request + PostSearchWithResponse(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*PostSearchResponse, error) + + // PostDelete request + PostDeleteWithResponse(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*PostDeleteResponse, error) + + // PostUpdate request with any body + PostUpdateWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) + + PostUpdateWithResponse(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) + + // PostReactAdd request with any body + PostReactAddWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) + + PostReactAddWithResponse(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) + + // ProfileGet request + ProfileGetWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*ProfileGetResponse, error) + + // ThreadList request + ThreadListWithResponse(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*ThreadListResponse, error) + + // ThreadCreate request with any body + ThreadCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) + + ThreadCreateWithResponse(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) + + // ThreadDelete request + ThreadDeleteWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadDeleteResponse, error) + + // ThreadGet request + ThreadGetWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadGetResponse, error) + + // ThreadUpdate request with any body + ThreadUpdateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) + + ThreadUpdateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) + + // PostCreate request with any body + PostCreateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) + + PostCreateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) + + // GetVersion request + GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) +} + +type GetSpecResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r GetSpecResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSpecResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccountGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Account + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AccountGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccountGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccountUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Account + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AccountUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccountUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccountAuthProviderListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AccountAuthMethods + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AccountAuthProviderListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccountAuthProviderListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccountSetAvatarResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AccountSetAvatarResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccountSetAvatarResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccountGetAvatarResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AccountGetAvatarResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccountGetAvatarResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AdminSettingsUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AdminSettingsProps + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AdminSettingsUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AdminSettingsUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AssetUploadResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Asset + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AssetUploadResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AssetUploadResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AssetGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AssetGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AssetGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AuthProviderListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Providers AuthProviderList `json:"providers"` + } + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AuthProviderListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AuthProviderListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AuthProviderLogoutResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AuthProviderLogoutResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AuthProviderLogoutResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type OAuthProviderCallbackResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r OAuthProviderCallbackResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r OAuthProviderCallbackResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AuthPasswordSigninResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AuthPasswordSigninResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AuthPasswordSigninResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AuthPasswordSignupResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r AuthPasswordSignupResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AuthPasswordSignupResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PhoneRequestCodeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PhoneRequestCodeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PhoneRequestCodeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PhoneSubmitCodeResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PhoneSubmitCodeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PhoneSubmitCodeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type WebAuthnMakeAssertionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r WebAuthnMakeAssertionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r WebAuthnMakeAssertionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type WebAuthnGetAssertionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CredentialRequestOptions + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r WebAuthnGetAssertionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r WebAuthnGetAssertionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type WebAuthnMakeCredentialResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AuthSuccess + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r WebAuthnMakeCredentialResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r WebAuthnMakeCredentialResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type WebAuthnRequestCredentialResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *WebAuthnPublicKeyCreationOptions + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r WebAuthnRequestCredentialResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r WebAuthnRequestCredentialResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CategoryListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CategoryList + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CategoryListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CategoryListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CategoryUpdateOrderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CategoryList + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CategoryUpdateOrderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CategoryUpdateOrderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CategoryCreateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Category + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CategoryCreateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CategoryCreateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CategoryUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Category + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CategoryUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CategoryUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Clusters ClusterList `json:"clusters"` + } + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterCreateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterCreateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterCreateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ClusterWithItems + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterRemoveClusterResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterRemoveClusterResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterRemoveClusterResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterAddClusterResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterAddClusterResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterAddClusterResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterRemoveItemResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterRemoveItemResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterRemoveItemResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClusterAddItemResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Cluster + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ClusterAddItemResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClusterAddItemResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CollectionListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Collections CollectionList `json:"collections"` + } + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CollectionListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CollectionListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CollectionCreateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Collection + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CollectionCreateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CollectionCreateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CollectionGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CollectionWithItems + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CollectionGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CollectionGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CollectionUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Collection + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CollectionUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CollectionUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CollectionRemovePostResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Collection + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r CollectionRemovePostResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode -func (r AuthProviderLogoutResponse) StatusCode() int { +func (r CollectionRemovePostResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type OAuthProviderCallbackResponse struct { +type CollectionAddPostResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess + JSON200 *Collection JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r OAuthProviderCallbackResponse) Status() string { +func (r CollectionAddPostResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4712,22 +6539,22 @@ func (r OAuthProviderCallbackResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r OAuthProviderCallbackResponse) StatusCode() int { +func (r CollectionAddPostResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type AuthPasswordSigninResponse struct { +type GetInfoResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess + JSON200 *Info JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r AuthPasswordSigninResponse) Status() string { +func (r GetInfoResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4735,22 +6562,279 @@ func (r AuthPasswordSigninResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r AuthPasswordSigninResponse) StatusCode() int { +func (r GetInfoResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type AuthPasswordSignupResponse struct { +type IconUploadResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r AuthPasswordSignupResponse) Status() string { +func (r IconUploadResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IconUploadResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type IconGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r IconGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IconGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ItemListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + // Clusters A list of items where each item includes all the information about its + // parent cluster too. For use with APIs that want to provide a list of + // items that may be part of different clusters. + Clusters ItemList `json:"clusters"` + } + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ItemListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ItemListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ItemCreateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Item + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ItemCreateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ItemCreateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ItemGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ItemWithParents + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ItemGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ItemGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ItemUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Item + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ItemUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ItemUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostSearchResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PostSearchResults + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PostSearchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostSearchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostDeleteResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PostDeleteResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostDeleteResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostUpdateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PostProps + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PostUpdateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostUpdateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostReactAddResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *React + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r PostReactAddResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostReactAddResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ProfileGetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PublicProfile + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ProfileGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProfileGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ThreadListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Threads ThreadList `json:"threads"` + } + JSONDefault *APIError +} + +// Status returns HTTPResponse.Status +func (r ThreadListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4758,22 +6842,22 @@ func (r AuthPasswordSignupResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r AuthPasswordSignupResponse) StatusCode() int { +func (r ThreadListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type PhoneRequestCodeResponse struct { +type ThreadCreateResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess + JSON200 *Thread JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r PhoneRequestCodeResponse) Status() string { +func (r ThreadCreateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4781,22 +6865,21 @@ func (r PhoneRequestCodeResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PhoneRequestCodeResponse) StatusCode() int { +func (r ThreadCreateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type PhoneSubmitCodeResponse struct { +type ThreadDeleteResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r PhoneSubmitCodeResponse) Status() string { +func (r ThreadDeleteResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4804,22 +6887,22 @@ func (r PhoneSubmitCodeResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PhoneSubmitCodeResponse) StatusCode() int { +func (r ThreadDeleteResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type WebAuthnMakeAssertionResponse struct { +type ThreadGetResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess + JSON200 *Thread JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r WebAuthnMakeAssertionResponse) Status() string { +func (r ThreadGetResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4827,22 +6910,22 @@ func (r WebAuthnMakeAssertionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r WebAuthnMakeAssertionResponse) StatusCode() int { +func (r ThreadGetResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type WebAuthnGetAssertionResponse struct { +type ThreadUpdateResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *CredentialRequestOptions + JSON200 *Thread JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r WebAuthnGetAssertionResponse) Status() string { +func (r ThreadUpdateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4850,22 +6933,22 @@ func (r WebAuthnGetAssertionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r WebAuthnGetAssertionResponse) StatusCode() int { +func (r ThreadUpdateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type WebAuthnMakeCredentialResponse struct { +type PostCreateResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *AuthSuccess + JSON200 *PostProps JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r WebAuthnMakeCredentialResponse) Status() string { +func (r PostCreateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4873,22 +6956,20 @@ func (r WebAuthnMakeCredentialResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r WebAuthnMakeCredentialResponse) StatusCode() int { +func (r PostCreateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type WebAuthnRequestCredentialResponse struct { +type GetVersionResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *WebAuthnPublicKeyCreationOptions - JSONDefault *APIError } // Status returns HTTPResponse.Status -func (r WebAuthnRequestCredentialResponse) Status() string { +func (r GetVersionResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -4896,1175 +6977,1609 @@ func (r WebAuthnRequestCredentialResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r WebAuthnRequestCredentialResponse) StatusCode() int { +func (r GetVersionResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CategoryListResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CategoryList - JSONDefault *APIError +// GetSpecWithResponse request returning *GetSpecResponse +func (c *ClientWithResponses) GetSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetSpecResponse, error) { + rsp, err := c.GetSpec(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSpecResponse(rsp) +} + +// AccountGetWithResponse request returning *AccountGetResponse +func (c *ClientWithResponses) AccountGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountGetResponse, error) { + rsp, err := c.AccountGet(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountGetResponse(rsp) +} + +// AccountUpdateWithBodyWithResponse request with arbitrary body returning *AccountUpdateResponse +func (c *ClientWithResponses) AccountUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) { + rsp, err := c.AccountUpdateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountUpdateResponse(rsp) +} + +func (c *ClientWithResponses) AccountUpdateWithResponse(ctx context.Context, body AccountUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) { + rsp, err := c.AccountUpdate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountUpdateResponse(rsp) +} + +// AccountAuthProviderListWithResponse request returning *AccountAuthProviderListResponse +func (c *ClientWithResponses) AccountAuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountAuthProviderListResponse, error) { + rsp, err := c.AccountAuthProviderList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountAuthProviderListResponse(rsp) +} + +// AccountSetAvatarWithBodyWithResponse request with arbitrary body returning *AccountSetAvatarResponse +func (c *ClientWithResponses) AccountSetAvatarWithBodyWithResponse(ctx context.Context, params *AccountSetAvatarParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountSetAvatarResponse, error) { + rsp, err := c.AccountSetAvatarWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountSetAvatarResponse(rsp) +} + +// AccountGetAvatarWithResponse request returning *AccountGetAvatarResponse +func (c *ClientWithResponses) AccountGetAvatarWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*AccountGetAvatarResponse, error) { + rsp, err := c.AccountGetAvatar(ctx, accountHandle, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccountGetAvatarResponse(rsp) +} + +// AdminSettingsUpdateWithBodyWithResponse request with arbitrary body returning *AdminSettingsUpdateResponse +func (c *ClientWithResponses) AdminSettingsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) { + rsp, err := c.AdminSettingsUpdateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAdminSettingsUpdateResponse(rsp) +} + +func (c *ClientWithResponses) AdminSettingsUpdateWithResponse(ctx context.Context, body AdminSettingsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) { + rsp, err := c.AdminSettingsUpdate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAdminSettingsUpdateResponse(rsp) +} + +// AssetUploadWithBodyWithResponse request with arbitrary body returning *AssetUploadResponse +func (c *ClientWithResponses) AssetUploadWithBodyWithResponse(ctx context.Context, params *AssetUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AssetUploadResponse, error) { + rsp, err := c.AssetUploadWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAssetUploadResponse(rsp) +} + +// AssetGetWithResponse request returning *AssetGetResponse +func (c *ClientWithResponses) AssetGetWithResponse(ctx context.Context, id AssetPath, reqEditors ...RequestEditorFn) (*AssetGetResponse, error) { + rsp, err := c.AssetGet(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseAssetGetResponse(rsp) +} + +// AuthProviderListWithResponse request returning *AuthProviderListResponse +func (c *ClientWithResponses) AuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderListResponse, error) { + rsp, err := c.AuthProviderList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthProviderListResponse(rsp) +} + +// AuthProviderLogoutWithResponse request returning *AuthProviderLogoutResponse +func (c *ClientWithResponses) AuthProviderLogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderLogoutResponse, error) { + rsp, err := c.AuthProviderLogout(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthProviderLogoutResponse(rsp) +} + +// OAuthProviderCallbackWithBodyWithResponse request with arbitrary body returning *OAuthProviderCallbackResponse +func (c *ClientWithResponses) OAuthProviderCallbackWithBodyWithResponse(ctx context.Context, oauthProvider OAuthProvider, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) { + rsp, err := c.OAuthProviderCallbackWithBody(ctx, oauthProvider, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseOAuthProviderCallbackResponse(rsp) +} + +func (c *ClientWithResponses) OAuthProviderCallbackWithResponse(ctx context.Context, oauthProvider OAuthProvider, body OAuthProviderCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) { + rsp, err := c.OAuthProviderCallback(ctx, oauthProvider, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseOAuthProviderCallbackResponse(rsp) +} + +// AuthPasswordSigninWithBodyWithResponse request with arbitrary body returning *AuthPasswordSigninResponse +func (c *ClientWithResponses) AuthPasswordSigninWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) { + rsp, err := c.AuthPasswordSigninWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthPasswordSigninResponse(rsp) +} + +func (c *ClientWithResponses) AuthPasswordSigninWithResponse(ctx context.Context, body AuthPasswordSigninJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) { + rsp, err := c.AuthPasswordSignin(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthPasswordSigninResponse(rsp) +} + +// AuthPasswordSignupWithBodyWithResponse request with arbitrary body returning *AuthPasswordSignupResponse +func (c *ClientWithResponses) AuthPasswordSignupWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) { + rsp, err := c.AuthPasswordSignupWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthPasswordSignupResponse(rsp) +} + +func (c *ClientWithResponses) AuthPasswordSignupWithResponse(ctx context.Context, body AuthPasswordSignupJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) { + rsp, err := c.AuthPasswordSignup(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthPasswordSignupResponse(rsp) +} + +// PhoneRequestCodeWithBodyWithResponse request with arbitrary body returning *PhoneRequestCodeResponse +func (c *ClientWithResponses) PhoneRequestCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) { + rsp, err := c.PhoneRequestCodeWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePhoneRequestCodeResponse(rsp) +} + +func (c *ClientWithResponses) PhoneRequestCodeWithResponse(ctx context.Context, body PhoneRequestCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) { + rsp, err := c.PhoneRequestCode(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePhoneRequestCodeResponse(rsp) +} + +// PhoneSubmitCodeWithBodyWithResponse request with arbitrary body returning *PhoneSubmitCodeResponse +func (c *ClientWithResponses) PhoneSubmitCodeWithBodyWithResponse(ctx context.Context, accountHandle AccountHandleParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) { + rsp, err := c.PhoneSubmitCodeWithBody(ctx, accountHandle, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePhoneSubmitCodeResponse(rsp) +} + +func (c *ClientWithResponses) PhoneSubmitCodeWithResponse(ctx context.Context, accountHandle AccountHandleParam, body PhoneSubmitCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) { + rsp, err := c.PhoneSubmitCode(ctx, accountHandle, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePhoneSubmitCodeResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CategoryListResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// WebAuthnMakeAssertionWithBodyWithResponse request with arbitrary body returning *WebAuthnMakeAssertionResponse +func (c *ClientWithResponses) WebAuthnMakeAssertionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) { + rsp, err := c.WebAuthnMakeAssertionWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseWebAuthnMakeAssertionResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CategoryListResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) WebAuthnMakeAssertionWithResponse(ctx context.Context, body WebAuthnMakeAssertionJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) { + rsp, err := c.WebAuthnMakeAssertion(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseWebAuthnMakeAssertionResponse(rsp) } -type CategoryUpdateOrderResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CategoryList - JSONDefault *APIError +// WebAuthnGetAssertionWithResponse request returning *WebAuthnGetAssertionResponse +func (c *ClientWithResponses) WebAuthnGetAssertionWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnGetAssertionResponse, error) { + rsp, err := c.WebAuthnGetAssertion(ctx, accountHandle, reqEditors...) + if err != nil { + return nil, err + } + return ParseWebAuthnGetAssertionResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CategoryUpdateOrderResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// WebAuthnMakeCredentialWithBodyWithResponse request with arbitrary body returning *WebAuthnMakeCredentialResponse +func (c *ClientWithResponses) WebAuthnMakeCredentialWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) { + rsp, err := c.WebAuthnMakeCredentialWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseWebAuthnMakeCredentialResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CategoryUpdateOrderResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) WebAuthnMakeCredentialWithResponse(ctx context.Context, body WebAuthnMakeCredentialJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) { + rsp, err := c.WebAuthnMakeCredential(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseWebAuthnMakeCredentialResponse(rsp) } -type CategoryCreateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Category - JSONDefault *APIError +// WebAuthnRequestCredentialWithResponse request returning *WebAuthnRequestCredentialResponse +func (c *ClientWithResponses) WebAuthnRequestCredentialWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnRequestCredentialResponse, error) { + rsp, err := c.WebAuthnRequestCredential(ctx, accountHandle, reqEditors...) + if err != nil { + return nil, err + } + return ParseWebAuthnRequestCredentialResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CategoryCreateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// CategoryListWithResponse request returning *CategoryListResponse +func (c *ClientWithResponses) CategoryListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CategoryListResponse, error) { + rsp, err := c.CategoryList(ctx, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCategoryListResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CategoryCreateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// CategoryUpdateOrderWithBodyWithResponse request with arbitrary body returning *CategoryUpdateOrderResponse +func (c *ClientWithResponses) CategoryUpdateOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) { + rsp, err := c.CategoryUpdateOrderWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseCategoryUpdateOrderResponse(rsp) } -type CategoryUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Category - JSONDefault *APIError +func (c *ClientWithResponses) CategoryUpdateOrderWithResponse(ctx context.Context, body CategoryUpdateOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) { + rsp, err := c.CategoryUpdateOrder(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCategoryUpdateOrderResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CategoryUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// CategoryCreateWithBodyWithResponse request with arbitrary body returning *CategoryCreateResponse +func (c *ClientWithResponses) CategoryCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) { + rsp, err := c.CategoryCreateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCategoryCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CategoryUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) CategoryCreateWithResponse(ctx context.Context, body CategoryCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) { + rsp, err := c.CategoryCreate(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseCategoryCreateResponse(rsp) } -type CollectionListResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Collections CollectionList `json:"collections"` +// CategoryUpdateWithBodyWithResponse request with arbitrary body returning *CategoryUpdateResponse +func (c *ClientWithResponses) CategoryUpdateWithBodyWithResponse(ctx context.Context, categoryId CategoryIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) { + rsp, err := c.CategoryUpdateWithBody(ctx, categoryId, contentType, body, reqEditors...) + if err != nil { + return nil, err } - JSONDefault *APIError + return ParseCategoryUpdateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionListResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) CategoryUpdateWithResponse(ctx context.Context, categoryId CategoryIDParam, body CategoryUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) { + rsp, err := c.CategoryUpdate(ctx, categoryId, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCategoryUpdateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionListResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ClusterListWithResponse request returning *ClusterListResponse +func (c *ClientWithResponses) ClusterListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ClusterListResponse, error) { + rsp, err := c.ClusterList(ctx, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseClusterListResponse(rsp) } -type CollectionCreateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSONDefault *APIError +// ClusterCreateWithBodyWithResponse request with arbitrary body returning *ClusterCreateResponse +func (c *ClientWithResponses) ClusterCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClusterCreateResponse, error) { + rsp, err := c.ClusterCreateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClusterCreateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionCreateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) ClusterCreateWithResponse(ctx context.Context, body ClusterCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClusterCreateResponse, error) { + rsp, err := c.ClusterCreate(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseClusterCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionCreateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ClusterGetWithResponse request returning *ClusterGetResponse +func (c *ClientWithResponses) ClusterGetWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, reqEditors ...RequestEditorFn) (*ClusterGetResponse, error) { + rsp, err := c.ClusterGet(ctx, clusterSlug, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseClusterGetResponse(rsp) } -type CollectionGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CollectionWithItems - JSONDefault *APIError +// ClusterUpdateWithBodyWithResponse request with arbitrary body returning *ClusterUpdateResponse +func (c *ClientWithResponses) ClusterUpdateWithBodyWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClusterUpdateResponse, error) { + rsp, err := c.ClusterUpdateWithBody(ctx, clusterSlug, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClusterUpdateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) ClusterUpdateWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, body ClusterUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClusterUpdateResponse, error) { + rsp, err := c.ClusterUpdate(ctx, clusterSlug, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseClusterUpdateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ClusterRemoveClusterWithResponse request returning *ClusterRemoveClusterResponse +func (c *ClientWithResponses) ClusterRemoveClusterWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*ClusterRemoveClusterResponse, error) { + rsp, err := c.ClusterRemoveCluster(ctx, clusterSlug, clusterSlugChild, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseClusterRemoveClusterResponse(rsp) } -type CollectionUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSONDefault *APIError +// ClusterAddClusterWithResponse request returning *ClusterAddClusterResponse +func (c *ClientWithResponses) ClusterAddClusterWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam, reqEditors ...RequestEditorFn) (*ClusterAddClusterResponse, error) { + rsp, err := c.ClusterAddCluster(ctx, clusterSlug, clusterSlugChild, reqEditors...) + if err != nil { + return nil, err + } + return ParseClusterAddClusterResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ClusterRemoveItemWithResponse request returning *ClusterRemoveItemResponse +func (c *ClientWithResponses) ClusterRemoveItemWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ClusterRemoveItemResponse, error) { + rsp, err := c.ClusterRemoveItem(ctx, clusterSlug, itemSlug, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseClusterRemoveItemResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ClusterAddItemWithResponse request returning *ClusterAddItemResponse +func (c *ClientWithResponses) ClusterAddItemWithResponse(ctx context.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ClusterAddItemResponse, error) { + rsp, err := c.ClusterAddItem(ctx, clusterSlug, itemSlug, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseClusterAddItemResponse(rsp) } -type CollectionRemovePostResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSONDefault *APIError +// CollectionListWithResponse request returning *CollectionListResponse +func (c *ClientWithResponses) CollectionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CollectionListResponse, error) { + rsp, err := c.CollectionList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseCollectionListResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionRemovePostResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// CollectionCreateWithBodyWithResponse request with arbitrary body returning *CollectionCreateResponse +func (c *ClientWithResponses) CollectionCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) { + rsp, err := c.CollectionCreateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCollectionCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionRemovePostResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) CollectionCreateWithResponse(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) { + rsp, err := c.CollectionCreate(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseCollectionCreateResponse(rsp) } -type CollectionAddPostResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Collection - JSONDefault *APIError +// CollectionGetWithResponse request returning *CollectionGetResponse +func (c *ClientWithResponses) CollectionGetWithResponse(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*CollectionGetResponse, error) { + rsp, err := c.CollectionGet(ctx, collectionId, reqEditors...) + if err != nil { + return nil, err + } + return ParseCollectionGetResponse(rsp) } -// Status returns HTTPResponse.Status -func (r CollectionAddPostResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// CollectionUpdateWithBodyWithResponse request with arbitrary body returning *CollectionUpdateResponse +func (c *ClientWithResponses) CollectionUpdateWithBodyWithResponse(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) { + rsp, err := c.CollectionUpdateWithBody(ctx, collectionId, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCollectionUpdateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r CollectionAddPostResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) CollectionUpdateWithResponse(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) { + rsp, err := c.CollectionUpdate(ctx, collectionId, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseCollectionUpdateResponse(rsp) } -type GetInfoResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Info - JSONDefault *APIError +// CollectionRemovePostWithResponse request returning *CollectionRemovePostResponse +func (c *ClientWithResponses) CollectionRemovePostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionRemovePostResponse, error) { + rsp, err := c.CollectionRemovePost(ctx, collectionId, postId, reqEditors...) + if err != nil { + return nil, err + } + return ParseCollectionRemovePostResponse(rsp) } -// Status returns HTTPResponse.Status -func (r GetInfoResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// CollectionAddPostWithResponse request returning *CollectionAddPostResponse +func (c *ClientWithResponses) CollectionAddPostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionAddPostResponse, error) { + rsp, err := c.CollectionAddPost(ctx, collectionId, postId, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseCollectionAddPostResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r GetInfoResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// GetInfoWithResponse request returning *GetInfoResponse +func (c *ClientWithResponses) GetInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetInfoResponse, error) { + rsp, err := c.GetInfo(ctx, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseGetInfoResponse(rsp) } -type IconUploadResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError +// IconUploadWithBodyWithResponse request with arbitrary body returning *IconUploadResponse +func (c *ClientWithResponses) IconUploadWithBodyWithResponse(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IconUploadResponse, error) { + rsp, err := c.IconUploadWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseIconUploadResponse(rsp) } -// Status returns HTTPResponse.Status -func (r IconUploadResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// IconGetWithResponse request returning *IconGetResponse +func (c *ClientWithResponses) IconGetWithResponse(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*IconGetResponse, error) { + rsp, err := c.IconGet(ctx, iconSize, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseIconGetResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r IconUploadResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ItemListWithResponse request returning *ItemListResponse +func (c *ClientWithResponses) ItemListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ItemListResponse, error) { + rsp, err := c.ItemList(ctx, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseItemListResponse(rsp) } -type IconGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError +// ItemCreateWithBodyWithResponse request with arbitrary body returning *ItemCreateResponse +func (c *ClientWithResponses) ItemCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemCreateResponse, error) { + rsp, err := c.ItemCreateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseItemCreateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r IconGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) ItemCreateWithResponse(ctx context.Context, body ItemCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemCreateResponse, error) { + rsp, err := c.ItemCreate(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseItemCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r IconGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ItemGetWithResponse request returning *ItemGetResponse +func (c *ClientWithResponses) ItemGetWithResponse(ctx context.Context, itemSlug ItemSlugParam, reqEditors ...RequestEditorFn) (*ItemGetResponse, error) { + rsp, err := c.ItemGet(ctx, itemSlug, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseItemGetResponse(rsp) } -type PostSearchResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *PostSearchResults - JSONDefault *APIError +// ItemUpdateWithBodyWithResponse request with arbitrary body returning *ItemUpdateResponse +func (c *ClientWithResponses) ItemUpdateWithBodyWithResponse(ctx context.Context, itemSlug ItemSlugParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemUpdateResponse, error) { + rsp, err := c.ItemUpdateWithBody(ctx, itemSlug, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseItemUpdateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r PostSearchResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) ItemUpdateWithResponse(ctx context.Context, itemSlug ItemSlugParam, body ItemUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemUpdateResponse, error) { + rsp, err := c.ItemUpdate(ctx, itemSlug, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseItemUpdateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r PostSearchResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// PostSearchWithResponse request returning *PostSearchResponse +func (c *ClientWithResponses) PostSearchWithResponse(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*PostSearchResponse, error) { + rsp, err := c.PostSearch(ctx, params, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParsePostSearchResponse(rsp) } -type PostDeleteResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError +// PostDeleteWithResponse request returning *PostDeleteResponse +func (c *ClientWithResponses) PostDeleteWithResponse(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*PostDeleteResponse, error) { + rsp, err := c.PostDelete(ctx, postId, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostDeleteResponse(rsp) } -// Status returns HTTPResponse.Status -func (r PostDeleteResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// PostUpdateWithBodyWithResponse request with arbitrary body returning *PostUpdateResponse +func (c *ClientWithResponses) PostUpdateWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) { + rsp, err := c.PostUpdateWithBody(ctx, postId, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParsePostUpdateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r PostDeleteResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) PostUpdateWithResponse(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) { + rsp, err := c.PostUpdate(ctx, postId, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParsePostUpdateResponse(rsp) } -type PostUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *PostProps - JSONDefault *APIError +// PostReactAddWithBodyWithResponse request with arbitrary body returning *PostReactAddResponse +func (c *ClientWithResponses) PostReactAddWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) { + rsp, err := c.PostReactAddWithBody(ctx, postId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostReactAddResponse(rsp) } -// Status returns HTTPResponse.Status -func (r PostUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *ClientWithResponses) PostReactAddWithResponse(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) { + rsp, err := c.PostReactAdd(ctx, postId, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParsePostReactAddResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r PostUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ProfileGetWithResponse request returning *ProfileGetResponse +func (c *ClientWithResponses) ProfileGetWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*ProfileGetResponse, error) { + rsp, err := c.ProfileGet(ctx, accountHandle, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseProfileGetResponse(rsp) } -type PostReactAddResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *React - JSONDefault *APIError +// ThreadListWithResponse request returning *ThreadListResponse +func (c *ClientWithResponses) ThreadListWithResponse(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*ThreadListResponse, error) { + rsp, err := c.ThreadList(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseThreadListResponse(rsp) } -// Status returns HTTPResponse.Status -func (r PostReactAddResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ThreadCreateWithBodyWithResponse request with arbitrary body returning *ThreadCreateResponse +func (c *ClientWithResponses) ThreadCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) { + rsp, err := c.ThreadCreateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseThreadCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r PostReactAddResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) ThreadCreateWithResponse(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) { + rsp, err := c.ThreadCreate(ctx, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseThreadCreateResponse(rsp) } -type ProfileGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *PublicProfile - JSONDefault *APIError +// ThreadDeleteWithResponse request returning *ThreadDeleteResponse +func (c *ClientWithResponses) ThreadDeleteWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadDeleteResponse, error) { + rsp, err := c.ThreadDelete(ctx, threadMark, reqEditors...) + if err != nil { + return nil, err + } + return ParseThreadDeleteResponse(rsp) } -// Status returns HTTPResponse.Status -func (r ProfileGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ThreadGetWithResponse request returning *ThreadGetResponse +func (c *ClientWithResponses) ThreadGetWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadGetResponse, error) { + rsp, err := c.ThreadGet(ctx, threadMark, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseThreadGetResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r ProfileGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ThreadUpdateWithBodyWithResponse request with arbitrary body returning *ThreadUpdateResponse +func (c *ClientWithResponses) ThreadUpdateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) { + rsp, err := c.ThreadUpdateWithBody(ctx, threadMark, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseThreadUpdateResponse(rsp) } -type ThreadListResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Threads ThreadList `json:"threads"` +func (c *ClientWithResponses) ThreadUpdateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) { + rsp, err := c.ThreadUpdate(ctx, threadMark, body, reqEditors...) + if err != nil { + return nil, err } - JSONDefault *APIError + return ParseThreadUpdateResponse(rsp) } -// Status returns HTTPResponse.Status -func (r ThreadListResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// PostCreateWithBodyWithResponse request with arbitrary body returning *PostCreateResponse +func (c *ClientWithResponses) PostCreateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) { + rsp, err := c.PostCreateWithBody(ctx, threadMark, contentType, body, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParsePostCreateResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r ThreadListResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +func (c *ClientWithResponses) PostCreateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) { + rsp, err := c.PostCreate(ctx, threadMark, body, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParsePostCreateResponse(rsp) } -type ThreadCreateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Thread - JSONDefault *APIError +// GetVersionWithResponse request returning *GetVersionResponse +func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) { + rsp, err := c.GetVersion(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVersionResponse(rsp) } -// Status returns HTTPResponse.Status -func (r ThreadCreateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ParseGetSpecResponse parses an HTTP response from a GetSpecWithResponse call +func ParseGetSpecResponse(rsp *http.Response) (*GetSpecResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ThreadCreateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + response := &GetSpecResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return 0 -} -type ThreadDeleteResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *APIError + return response, nil } -// Status returns HTTPResponse.Status -func (r ThreadDeleteResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ParseAccountGetResponse parses an HTTP response from a AccountGetWithResponse call +func ParseAccountGetResponse(rsp *http.Response) (*AccountGetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ThreadDeleteResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + response := &AccountGetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return 0 -} -type ThreadGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Thread - JSONDefault *APIError -} + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Account + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest -// Status returns HTTPResponse.Status -func (r ThreadGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest -// StatusCode returns HTTPResponse.StatusCode -func (r ThreadGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode } - return 0 -} -type ThreadUpdateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Thread - JSONDefault *APIError + return response, nil } -// Status returns HTTPResponse.Status -func (r ThreadUpdateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// ParseAccountUpdateResponse parses an HTTP response from a AccountUpdateWithResponse call +func ParseAccountUpdateResponse(rsp *http.Response) (*AccountUpdateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ThreadUpdateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + response := &AccountUpdateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return 0 -} -type PostCreateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *PostProps - JSONDefault *APIError -} + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Account + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest -// Status returns HTTPResponse.Status -func (r PostCreateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status } - return http.StatusText(0) + + return response, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r PostCreateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ParseAccountAuthProviderListResponse parses an HTTP response from a AccountAuthProviderListWithResponse call +func ParseAccountAuthProviderListResponse(rsp *http.Response) (*AccountAuthProviderListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err } - return 0 -} -type GetVersionResponse struct { - Body []byte - HTTPResponse *http.Response -} + response := &AccountAuthProviderListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AccountAuthMethods + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest -// Status returns HTTPResponse.Status -func (r GetVersionResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status } - return http.StatusText(0) + + return response, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r GetVersionResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// ParseAccountSetAvatarResponse parses an HTTP response from a AccountSetAvatarWithResponse call +func ParseAccountSetAvatarResponse(rsp *http.Response) (*AccountSetAvatarResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AccountSetAvatarResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return 0 + + return response, nil } -// GetSpecWithResponse request returning *GetSpecResponse -func (c *ClientWithResponses) GetSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetSpecResponse, error) { - rsp, err := c.GetSpec(ctx, reqEditors...) +// ParseAccountGetAvatarResponse parses an HTTP response from a AccountGetAvatarWithResponse call +func ParseAccountGetAvatarResponse(rsp *http.Response) (*AccountGetAvatarResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseGetSpecResponse(rsp) -} -// AccountGetWithResponse request returning *AccountGetResponse -func (c *ClientWithResponses) AccountGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountGetResponse, error) { - rsp, err := c.AccountGet(ctx, reqEditors...) - if err != nil { - return nil, err + response := &AccountGetAvatarResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseAccountGetResponse(rsp) -} -// AccountUpdateWithBodyWithResponse request with arbitrary body returning *AccountUpdateResponse -func (c *ClientWithResponses) AccountUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) { - rsp, err := c.AccountUpdateWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseAccountUpdateResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) AccountUpdateWithResponse(ctx context.Context, body AccountUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AccountUpdateResponse, error) { - rsp, err := c.AccountUpdate(ctx, body, reqEditors...) +// ParseAdminSettingsUpdateResponse parses an HTTP response from a AdminSettingsUpdateWithResponse call +func ParseAdminSettingsUpdateResponse(rsp *http.Response) (*AdminSettingsUpdateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAccountUpdateResponse(rsp) -} -// AccountAuthProviderListWithResponse request returning *AccountAuthProviderListResponse -func (c *ClientWithResponses) AccountAuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccountAuthProviderListResponse, error) { - rsp, err := c.AccountAuthProviderList(ctx, reqEditors...) - if err != nil { - return nil, err + response := &AdminSettingsUpdateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseAccountAuthProviderListResponse(rsp) -} -// AccountSetAvatarWithBodyWithResponse request with arbitrary body returning *AccountSetAvatarResponse -func (c *ClientWithResponses) AccountSetAvatarWithBodyWithResponse(ctx context.Context, params *AccountSetAvatarParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccountSetAvatarResponse, error) { - rsp, err := c.AccountSetAvatarWithBody(ctx, params, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AdminSettingsProps + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseAccountSetAvatarResponse(rsp) + + return response, nil } -// AccountGetAvatarWithResponse request returning *AccountGetAvatarResponse -func (c *ClientWithResponses) AccountGetAvatarWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*AccountGetAvatarResponse, error) { - rsp, err := c.AccountGetAvatar(ctx, accountHandle, reqEditors...) +// ParseAssetUploadResponse parses an HTTP response from a AssetUploadWithResponse call +func ParseAssetUploadResponse(rsp *http.Response) (*AssetUploadResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAccountGetAvatarResponse(rsp) -} -// AdminSettingsUpdateWithBodyWithResponse request with arbitrary body returning *AdminSettingsUpdateResponse -func (c *ClientWithResponses) AdminSettingsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) { - rsp, err := c.AdminSettingsUpdateWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &AssetUploadResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseAdminSettingsUpdateResponse(rsp) -} -func (c *ClientWithResponses) AdminSettingsUpdateWithResponse(ctx context.Context, body AdminSettingsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*AdminSettingsUpdateResponse, error) { - rsp, err := c.AdminSettingsUpdate(ctx, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Asset + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseAdminSettingsUpdateResponse(rsp) + + return response, nil } -// AssetUploadWithBodyWithResponse request with arbitrary body returning *AssetUploadResponse -func (c *ClientWithResponses) AssetUploadWithBodyWithResponse(ctx context.Context, params *AssetUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AssetUploadResponse, error) { - rsp, err := c.AssetUploadWithBody(ctx, params, contentType, body, reqEditors...) +// ParseAssetGetResponse parses an HTTP response from a AssetGetWithResponse call +func ParseAssetGetResponse(rsp *http.Response) (*AssetGetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAssetUploadResponse(rsp) -} -// AssetGetWithResponse request returning *AssetGetResponse -func (c *ClientWithResponses) AssetGetWithResponse(ctx context.Context, id AssetPath, reqEditors ...RequestEditorFn) (*AssetGetResponse, error) { - rsp, err := c.AssetGet(ctx, id, reqEditors...) - if err != nil { - return nil, err + response := &AssetGetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseAssetGetResponse(rsp) -} -// AuthProviderListWithResponse request returning *AuthProviderListResponse -func (c *ClientWithResponses) AuthProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderListResponse, error) { - rsp, err := c.AuthProviderList(ctx, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseAuthProviderListResponse(rsp) + + return response, nil } -// AuthProviderLogoutWithResponse request returning *AuthProviderLogoutResponse -func (c *ClientWithResponses) AuthProviderLogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AuthProviderLogoutResponse, error) { - rsp, err := c.AuthProviderLogout(ctx, reqEditors...) +// ParseAuthProviderListResponse parses an HTTP response from a AuthProviderListWithResponse call +func ParseAuthProviderListResponse(rsp *http.Response) (*AuthProviderListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAuthProviderLogoutResponse(rsp) -} -// OAuthProviderCallbackWithBodyWithResponse request with arbitrary body returning *OAuthProviderCallbackResponse -func (c *ClientWithResponses) OAuthProviderCallbackWithBodyWithResponse(ctx context.Context, oauthProvider OAuthProvider, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) { - rsp, err := c.OAuthProviderCallbackWithBody(ctx, oauthProvider, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &AuthProviderListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseOAuthProviderCallbackResponse(rsp) -} -func (c *ClientWithResponses) OAuthProviderCallbackWithResponse(ctx context.Context, oauthProvider OAuthProvider, body OAuthProviderCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*OAuthProviderCallbackResponse, error) { - rsp, err := c.OAuthProviderCallback(ctx, oauthProvider, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Providers AuthProviderList `json:"providers"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseOAuthProviderCallbackResponse(rsp) + + return response, nil } -// AuthPasswordSigninWithBodyWithResponse request with arbitrary body returning *AuthPasswordSigninResponse -func (c *ClientWithResponses) AuthPasswordSigninWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) { - rsp, err := c.AuthPasswordSigninWithBody(ctx, contentType, body, reqEditors...) +// ParseAuthProviderLogoutResponse parses an HTTP response from a AuthProviderLogoutWithResponse call +func ParseAuthProviderLogoutResponse(rsp *http.Response) (*AuthProviderLogoutResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAuthPasswordSigninResponse(rsp) -} -func (c *ClientWithResponses) AuthPasswordSigninWithResponse(ctx context.Context, body AuthPasswordSigninJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSigninResponse, error) { - rsp, err := c.AuthPasswordSignin(ctx, body, reqEditors...) - if err != nil { - return nil, err + response := &AuthProviderLogoutResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseAuthPasswordSigninResponse(rsp) -} -// AuthPasswordSignupWithBodyWithResponse request with arbitrary body returning *AuthPasswordSignupResponse -func (c *ClientWithResponses) AuthPasswordSignupWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) { - rsp, err := c.AuthPasswordSignupWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseAuthPasswordSignupResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) AuthPasswordSignupWithResponse(ctx context.Context, body AuthPasswordSignupJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthPasswordSignupResponse, error) { - rsp, err := c.AuthPasswordSignup(ctx, body, reqEditors...) +// ParseOAuthProviderCallbackResponse parses an HTTP response from a OAuthProviderCallbackWithResponse call +func ParseOAuthProviderCallbackResponse(rsp *http.Response) (*OAuthProviderCallbackResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseAuthPasswordSignupResponse(rsp) -} -// PhoneRequestCodeWithBodyWithResponse request with arbitrary body returning *PhoneRequestCodeResponse -func (c *ClientWithResponses) PhoneRequestCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) { - rsp, err := c.PhoneRequestCodeWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &OAuthProviderCallbackResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParsePhoneRequestCodeResponse(rsp) -} -func (c *ClientWithResponses) PhoneRequestCodeWithResponse(ctx context.Context, body PhoneRequestCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneRequestCodeResponse, error) { - rsp, err := c.PhoneRequestCode(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePhoneRequestCodeResponse(rsp) + return response, nil } -// PhoneSubmitCodeWithBodyWithResponse request with arbitrary body returning *PhoneSubmitCodeResponse -func (c *ClientWithResponses) PhoneSubmitCodeWithBodyWithResponse(ctx context.Context, accountHandle AccountHandleParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) { - rsp, err := c.PhoneSubmitCodeWithBody(ctx, accountHandle, contentType, body, reqEditors...) +// ParseAuthPasswordSigninResponse parses an HTTP response from a AuthPasswordSigninWithResponse call +func ParseAuthPasswordSigninResponse(rsp *http.Response) (*AuthPasswordSigninResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParsePhoneSubmitCodeResponse(rsp) -} -func (c *ClientWithResponses) PhoneSubmitCodeWithResponse(ctx context.Context, accountHandle AccountHandleParam, body PhoneSubmitCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*PhoneSubmitCodeResponse, error) { - rsp, err := c.PhoneSubmitCode(ctx, accountHandle, body, reqEditors...) - if err != nil { - return nil, err + response := &AuthPasswordSigninResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParsePhoneSubmitCodeResponse(rsp) -} -// WebAuthnMakeAssertionWithBodyWithResponse request with arbitrary body returning *WebAuthnMakeAssertionResponse -func (c *ClientWithResponses) WebAuthnMakeAssertionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) { - rsp, err := c.WebAuthnMakeAssertionWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseWebAuthnMakeAssertionResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) WebAuthnMakeAssertionWithResponse(ctx context.Context, body WebAuthnMakeAssertionJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeAssertionResponse, error) { - rsp, err := c.WebAuthnMakeAssertion(ctx, body, reqEditors...) +// ParseAuthPasswordSignupResponse parses an HTTP response from a AuthPasswordSignupWithResponse call +func ParseAuthPasswordSignupResponse(rsp *http.Response) (*AuthPasswordSignupResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseWebAuthnMakeAssertionResponse(rsp) -} -// WebAuthnGetAssertionWithResponse request returning *WebAuthnGetAssertionResponse -func (c *ClientWithResponses) WebAuthnGetAssertionWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnGetAssertionResponse, error) { - rsp, err := c.WebAuthnGetAssertion(ctx, accountHandle, reqEditors...) - if err != nil { - return nil, err + response := &AuthPasswordSignupResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseWebAuthnGetAssertionResponse(rsp) -} -// WebAuthnMakeCredentialWithBodyWithResponse request with arbitrary body returning *WebAuthnMakeCredentialResponse -func (c *ClientWithResponses) WebAuthnMakeCredentialWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) { - rsp, err := c.WebAuthnMakeCredentialWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseWebAuthnMakeCredentialResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) WebAuthnMakeCredentialWithResponse(ctx context.Context, body WebAuthnMakeCredentialJSONRequestBody, reqEditors ...RequestEditorFn) (*WebAuthnMakeCredentialResponse, error) { - rsp, err := c.WebAuthnMakeCredential(ctx, body, reqEditors...) +// ParsePhoneRequestCodeResponse parses an HTTP response from a PhoneRequestCodeWithResponse call +func ParsePhoneRequestCodeResponse(rsp *http.Response) (*PhoneRequestCodeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseWebAuthnMakeCredentialResponse(rsp) -} -// WebAuthnRequestCredentialWithResponse request returning *WebAuthnRequestCredentialResponse -func (c *ClientWithResponses) WebAuthnRequestCredentialWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*WebAuthnRequestCredentialResponse, error) { - rsp, err := c.WebAuthnRequestCredential(ctx, accountHandle, reqEditors...) - if err != nil { - return nil, err + response := &PhoneRequestCodeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseWebAuthnRequestCredentialResponse(rsp) -} -// CategoryListWithResponse request returning *CategoryListResponse -func (c *ClientWithResponses) CategoryListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CategoryListResponse, error) { - rsp, err := c.CategoryList(ctx, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseCategoryListResponse(rsp) + + return response, nil } -// CategoryUpdateOrderWithBodyWithResponse request with arbitrary body returning *CategoryUpdateOrderResponse -func (c *ClientWithResponses) CategoryUpdateOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) { - rsp, err := c.CategoryUpdateOrderWithBody(ctx, contentType, body, reqEditors...) +// ParsePhoneSubmitCodeResponse parses an HTTP response from a PhoneSubmitCodeWithResponse call +func ParsePhoneSubmitCodeResponse(rsp *http.Response) (*PhoneSubmitCodeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseCategoryUpdateOrderResponse(rsp) -} -func (c *ClientWithResponses) CategoryUpdateOrderWithResponse(ctx context.Context, body CategoryUpdateOrderJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateOrderResponse, error) { - rsp, err := c.CategoryUpdateOrder(ctx, body, reqEditors...) - if err != nil { - return nil, err + response := &PhoneSubmitCodeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseCategoryUpdateOrderResponse(rsp) -} -// CategoryCreateWithBodyWithResponse request with arbitrary body returning *CategoryCreateResponse -func (c *ClientWithResponses) CategoryCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) { - rsp, err := c.CategoryCreateWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseCategoryCreateResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) CategoryCreateWithResponse(ctx context.Context, body CategoryCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryCreateResponse, error) { - rsp, err := c.CategoryCreate(ctx, body, reqEditors...) +// ParseWebAuthnMakeAssertionResponse parses an HTTP response from a WebAuthnMakeAssertionWithResponse call +func ParseWebAuthnMakeAssertionResponse(rsp *http.Response) (*WebAuthnMakeAssertionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseCategoryCreateResponse(rsp) -} -// CategoryUpdateWithBodyWithResponse request with arbitrary body returning *CategoryUpdateResponse -func (c *ClientWithResponses) CategoryUpdateWithBodyWithResponse(ctx context.Context, categoryId CategoryIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) { - rsp, err := c.CategoryUpdateWithBody(ctx, categoryId, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &WebAuthnMakeAssertionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseCategoryUpdateResponse(rsp) -} -func (c *ClientWithResponses) CategoryUpdateWithResponse(ctx context.Context, categoryId CategoryIDParam, body CategoryUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CategoryUpdateResponse, error) { - rsp, err := c.CategoryUpdate(ctx, categoryId, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseCategoryUpdateResponse(rsp) + + return response, nil } -// CollectionListWithResponse request returning *CollectionListResponse -func (c *ClientWithResponses) CollectionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CollectionListResponse, error) { - rsp, err := c.CollectionList(ctx, reqEditors...) +// ParseWebAuthnGetAssertionResponse parses an HTTP response from a WebAuthnGetAssertionWithResponse call +func ParseWebAuthnGetAssertionResponse(rsp *http.Response) (*WebAuthnGetAssertionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseCollectionListResponse(rsp) -} -// CollectionCreateWithBodyWithResponse request with arbitrary body returning *CollectionCreateResponse -func (c *ClientWithResponses) CollectionCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) { - rsp, err := c.CollectionCreateWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &WebAuthnGetAssertionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseCollectionCreateResponse(rsp) -} -func (c *ClientWithResponses) CollectionCreateWithResponse(ctx context.Context, body CollectionCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionCreateResponse, error) { - rsp, err := c.CollectionCreate(ctx, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CredentialRequestOptions + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseCollectionCreateResponse(rsp) + + return response, nil } -// CollectionGetWithResponse request returning *CollectionGetResponse -func (c *ClientWithResponses) CollectionGetWithResponse(ctx context.Context, collectionId CollectionIDParam, reqEditors ...RequestEditorFn) (*CollectionGetResponse, error) { - rsp, err := c.CollectionGet(ctx, collectionId, reqEditors...) +// ParseWebAuthnMakeCredentialResponse parses an HTTP response from a WebAuthnMakeCredentialWithResponse call +func ParseWebAuthnMakeCredentialResponse(rsp *http.Response) (*WebAuthnMakeCredentialResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseCollectionGetResponse(rsp) -} -// CollectionUpdateWithBodyWithResponse request with arbitrary body returning *CollectionUpdateResponse -func (c *ClientWithResponses) CollectionUpdateWithBodyWithResponse(ctx context.Context, collectionId CollectionIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) { - rsp, err := c.CollectionUpdateWithBody(ctx, collectionId, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &WebAuthnMakeCredentialResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseCollectionUpdateResponse(rsp) -} -func (c *ClientWithResponses) CollectionUpdateWithResponse(ctx context.Context, collectionId CollectionIDParam, body CollectionUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*CollectionUpdateResponse, error) { - rsp, err := c.CollectionUpdate(ctx, collectionId, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuthSuccess + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseCollectionUpdateResponse(rsp) + + return response, nil } -// CollectionRemovePostWithResponse request returning *CollectionRemovePostResponse -func (c *ClientWithResponses) CollectionRemovePostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionRemovePostResponse, error) { - rsp, err := c.CollectionRemovePost(ctx, collectionId, postId, reqEditors...) +// ParseWebAuthnRequestCredentialResponse parses an HTTP response from a WebAuthnRequestCredentialWithResponse call +func ParseWebAuthnRequestCredentialResponse(rsp *http.Response) (*WebAuthnRequestCredentialResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseCollectionRemovePostResponse(rsp) -} -// CollectionAddPostWithResponse request returning *CollectionAddPostResponse -func (c *ClientWithResponses) CollectionAddPostWithResponse(ctx context.Context, collectionId CollectionIDParam, postId PostIDParam, reqEditors ...RequestEditorFn) (*CollectionAddPostResponse, error) { - rsp, err := c.CollectionAddPost(ctx, collectionId, postId, reqEditors...) - if err != nil { - return nil, err + response := &WebAuthnRequestCredentialResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseCollectionAddPostResponse(rsp) -} -// GetInfoWithResponse request returning *GetInfoResponse -func (c *ClientWithResponses) GetInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetInfoResponse, error) { - rsp, err := c.GetInfo(ctx, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest WebAuthnPublicKeyCreationOptions + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseGetInfoResponse(rsp) + + return response, nil } -// IconUploadWithBodyWithResponse request with arbitrary body returning *IconUploadResponse -func (c *ClientWithResponses) IconUploadWithBodyWithResponse(ctx context.Context, params *IconUploadParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IconUploadResponse, error) { - rsp, err := c.IconUploadWithBody(ctx, params, contentType, body, reqEditors...) +// ParseCategoryListResponse parses an HTTP response from a CategoryListWithResponse call +func ParseCategoryListResponse(rsp *http.Response) (*CategoryListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseIconUploadResponse(rsp) -} -// IconGetWithResponse request returning *IconGetResponse -func (c *ClientWithResponses) IconGetWithResponse(ctx context.Context, iconSize IconGetParamsIconSize, reqEditors ...RequestEditorFn) (*IconGetResponse, error) { - rsp, err := c.IconGet(ctx, iconSize, reqEditors...) - if err != nil { - return nil, err + response := &CategoryListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseIconGetResponse(rsp) -} -// PostSearchWithResponse request returning *PostSearchResponse -func (c *ClientWithResponses) PostSearchWithResponse(ctx context.Context, params *PostSearchParams, reqEditors ...RequestEditorFn) (*PostSearchResponse, error) { - rsp, err := c.PostSearch(ctx, params, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CategoryList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParsePostSearchResponse(rsp) + + return response, nil } -// PostDeleteWithResponse request returning *PostDeleteResponse -func (c *ClientWithResponses) PostDeleteWithResponse(ctx context.Context, postId PostIDParam, reqEditors ...RequestEditorFn) (*PostDeleteResponse, error) { - rsp, err := c.PostDelete(ctx, postId, reqEditors...) +// ParseCategoryUpdateOrderResponse parses an HTTP response from a CategoryUpdateOrderWithResponse call +func ParseCategoryUpdateOrderResponse(rsp *http.Response) (*CategoryUpdateOrderResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParsePostDeleteResponse(rsp) -} -// PostUpdateWithBodyWithResponse request with arbitrary body returning *PostUpdateResponse -func (c *ClientWithResponses) PostUpdateWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) { - rsp, err := c.PostUpdateWithBody(ctx, postId, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &CategoryUpdateOrderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParsePostUpdateResponse(rsp) -} -func (c *ClientWithResponses) PostUpdateWithResponse(ctx context.Context, postId PostIDParam, body PostUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostUpdateResponse, error) { - rsp, err := c.PostUpdate(ctx, postId, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CategoryList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParsePostUpdateResponse(rsp) + + return response, nil } -// PostReactAddWithBodyWithResponse request with arbitrary body returning *PostReactAddResponse -func (c *ClientWithResponses) PostReactAddWithBodyWithResponse(ctx context.Context, postId PostIDParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) { - rsp, err := c.PostReactAddWithBody(ctx, postId, contentType, body, reqEditors...) +// ParseCategoryCreateResponse parses an HTTP response from a CategoryCreateWithResponse call +func ParseCategoryCreateResponse(rsp *http.Response) (*CategoryCreateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParsePostReactAddResponse(rsp) -} -func (c *ClientWithResponses) PostReactAddWithResponse(ctx context.Context, postId PostIDParam, body PostReactAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostReactAddResponse, error) { - rsp, err := c.PostReactAdd(ctx, postId, body, reqEditors...) - if err != nil { - return nil, err + response := &CategoryCreateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParsePostReactAddResponse(rsp) -} -// ProfileGetWithResponse request returning *ProfileGetResponse -func (c *ClientWithResponses) ProfileGetWithResponse(ctx context.Context, accountHandle AccountHandleParam, reqEditors ...RequestEditorFn) (*ProfileGetResponse, error) { - rsp, err := c.ProfileGet(ctx, accountHandle, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Category + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseProfileGetResponse(rsp) + + return response, nil } -// ThreadListWithResponse request returning *ThreadListResponse -func (c *ClientWithResponses) ThreadListWithResponse(ctx context.Context, params *ThreadListParams, reqEditors ...RequestEditorFn) (*ThreadListResponse, error) { - rsp, err := c.ThreadList(ctx, params, reqEditors...) +// ParseCategoryUpdateResponse parses an HTTP response from a CategoryUpdateWithResponse call +func ParseCategoryUpdateResponse(rsp *http.Response) (*CategoryUpdateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseThreadListResponse(rsp) -} -// ThreadCreateWithBodyWithResponse request with arbitrary body returning *ThreadCreateResponse -func (c *ClientWithResponses) ThreadCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) { - rsp, err := c.ThreadCreateWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &CategoryUpdateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseThreadCreateResponse(rsp) -} -func (c *ClientWithResponses) ThreadCreateWithResponse(ctx context.Context, body ThreadCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadCreateResponse, error) { - rsp, err := c.ThreadCreate(ctx, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Category + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseThreadCreateResponse(rsp) + + return response, nil } -// ThreadDeleteWithResponse request returning *ThreadDeleteResponse -func (c *ClientWithResponses) ThreadDeleteWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadDeleteResponse, error) { - rsp, err := c.ThreadDelete(ctx, threadMark, reqEditors...) +// ParseClusterListResponse parses an HTTP response from a ClusterListWithResponse call +func ParseClusterListResponse(rsp *http.Response) (*ClusterListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseThreadDeleteResponse(rsp) -} -// ThreadGetWithResponse request returning *ThreadGetResponse -func (c *ClientWithResponses) ThreadGetWithResponse(ctx context.Context, threadMark ThreadMarkParam, reqEditors ...RequestEditorFn) (*ThreadGetResponse, error) { - rsp, err := c.ThreadGet(ctx, threadMark, reqEditors...) - if err != nil { - return nil, err + response := &ClusterListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseThreadGetResponse(rsp) -} -// ThreadUpdateWithBodyWithResponse request with arbitrary body returning *ThreadUpdateResponse -func (c *ClientWithResponses) ThreadUpdateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) { - rsp, err := c.ThreadUpdateWithBody(ctx, threadMark, contentType, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Clusters ClusterList `json:"clusters"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParseThreadUpdateResponse(rsp) + + return response, nil } -func (c *ClientWithResponses) ThreadUpdateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body ThreadUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ThreadUpdateResponse, error) { - rsp, err := c.ThreadUpdate(ctx, threadMark, body, reqEditors...) +// ParseClusterCreateResponse parses an HTTP response from a ClusterCreateWithResponse call +func ParseClusterCreateResponse(rsp *http.Response) (*ClusterCreateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseThreadUpdateResponse(rsp) -} -// PostCreateWithBodyWithResponse request with arbitrary body returning *PostCreateResponse -func (c *ClientWithResponses) PostCreateWithBodyWithResponse(ctx context.Context, threadMark ThreadMarkParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) { - rsp, err := c.PostCreateWithBody(ctx, threadMark, contentType, body, reqEditors...) - if err != nil { - return nil, err + response := &ClusterCreateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParsePostCreateResponse(rsp) -} -func (c *ClientWithResponses) PostCreateWithResponse(ctx context.Context, threadMark ThreadMarkParam, body PostCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*PostCreateResponse, error) { - rsp, err := c.PostCreate(ctx, threadMark, body, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Cluster + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + } - return ParsePostCreateResponse(rsp) + + return response, nil } -// GetVersionWithResponse request returning *GetVersionResponse -func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) { - rsp, err := c.GetVersion(ctx, reqEditors...) +// ParseClusterGetResponse parses an HTTP response from a ClusterGetWithResponse call +func ParseClusterGetResponse(rsp *http.Response) (*ClusterGetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseGetVersionResponse(rsp) + + response := &ClusterGetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ClusterWithItems + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil } -// ParseGetSpecResponse parses an HTTP response from a GetSpecWithResponse call -func ParseGetSpecResponse(rsp *http.Response) (*GetSpecResponse, error) { +// ParseClusterUpdateResponse parses an HTTP response from a ClusterUpdateWithResponse call +func ParseClusterUpdateResponse(rsp *http.Response) (*ClusterUpdateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetSpecResponse{ + response := &ClusterUpdateResponse{ Body: bodyBytes, HTTPResponse: rsp, } + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Cluster + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + return response, nil } -// ParseAccountGetResponse parses an HTTP response from a AccountGetWithResponse call -func ParseAccountGetResponse(rsp *http.Response) (*AccountGetResponse, error) { +// ParseClusterRemoveClusterResponse parses an HTTP response from a ClusterRemoveClusterWithResponse call +func ParseClusterRemoveClusterResponse(rsp *http.Response) (*ClusterRemoveClusterResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AccountGetResponse{ + response := &ClusterRemoveClusterResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Account + var dest Cluster if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6082,22 +8597,22 @@ func ParseAccountGetResponse(rsp *http.Response) (*AccountGetResponse, error) { return response, nil } -// ParseAccountUpdateResponse parses an HTTP response from a AccountUpdateWithResponse call -func ParseAccountUpdateResponse(rsp *http.Response) (*AccountUpdateResponse, error) { +// ParseClusterAddClusterResponse parses an HTTP response from a ClusterAddClusterWithResponse call +func ParseClusterAddClusterResponse(rsp *http.Response) (*ClusterAddClusterResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AccountUpdateResponse{ + response := &ClusterAddClusterResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Account + var dest Cluster if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6115,22 +8630,22 @@ func ParseAccountUpdateResponse(rsp *http.Response) (*AccountUpdateResponse, err return response, nil } -// ParseAccountAuthProviderListResponse parses an HTTP response from a AccountAuthProviderListWithResponse call -func ParseAccountAuthProviderListResponse(rsp *http.Response) (*AccountAuthProviderListResponse, error) { +// ParseClusterRemoveItemResponse parses an HTTP response from a ClusterRemoveItemWithResponse call +func ParseClusterRemoveItemResponse(rsp *http.Response) (*ClusterRemoveItemResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AccountAuthProviderListResponse{ + response := &ClusterRemoveItemResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AccountAuthMethods + var dest Cluster if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6148,20 +8663,27 @@ func ParseAccountAuthProviderListResponse(rsp *http.Response) (*AccountAuthProvi return response, nil } -// ParseAccountSetAvatarResponse parses an HTTP response from a AccountSetAvatarWithResponse call -func ParseAccountSetAvatarResponse(rsp *http.Response) (*AccountSetAvatarResponse, error) { +// ParseClusterAddItemResponse parses an HTTP response from a ClusterAddItemWithResponse call +func ParseClusterAddItemResponse(rsp *http.Response) (*ClusterAddItemResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AccountSetAvatarResponse{ + response := &ClusterAddItemResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Cluster + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6174,20 +8696,29 @@ func ParseAccountSetAvatarResponse(rsp *http.Response) (*AccountSetAvatarRespons return response, nil } -// ParseAccountGetAvatarResponse parses an HTTP response from a AccountGetAvatarWithResponse call -func ParseAccountGetAvatarResponse(rsp *http.Response) (*AccountGetAvatarResponse, error) { +// ParseCollectionListResponse parses an HTTP response from a CollectionListWithResponse call +func ParseCollectionListResponse(rsp *http.Response) (*CollectionListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AccountGetAvatarResponse{ + response := &CollectionListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Collections CollectionList `json:"collections"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6200,22 +8731,22 @@ func ParseAccountGetAvatarResponse(rsp *http.Response) (*AccountGetAvatarRespons return response, nil } -// ParseAdminSettingsUpdateResponse parses an HTTP response from a AdminSettingsUpdateWithResponse call -func ParseAdminSettingsUpdateResponse(rsp *http.Response) (*AdminSettingsUpdateResponse, error) { +// ParseCollectionCreateResponse parses an HTTP response from a CollectionCreateWithResponse call +func ParseCollectionCreateResponse(rsp *http.Response) (*CollectionCreateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AdminSettingsUpdateResponse{ + response := &CollectionCreateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AdminSettingsProps + var dest Collection if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6233,22 +8764,22 @@ func ParseAdminSettingsUpdateResponse(rsp *http.Response) (*AdminSettingsUpdateR return response, nil } -// ParseAssetUploadResponse parses an HTTP response from a AssetUploadWithResponse call -func ParseAssetUploadResponse(rsp *http.Response) (*AssetUploadResponse, error) { +// ParseCollectionGetResponse parses an HTTP response from a CollectionGetWithResponse call +func ParseCollectionGetResponse(rsp *http.Response) (*CollectionGetResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AssetUploadResponse{ + response := &CollectionGetResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Asset + var dest CollectionWithItems if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6266,20 +8797,27 @@ func ParseAssetUploadResponse(rsp *http.Response) (*AssetUploadResponse, error) return response, nil } -// ParseAssetGetResponse parses an HTTP response from a AssetGetWithResponse call -func ParseAssetGetResponse(rsp *http.Response) (*AssetGetResponse, error) { +// ParseCollectionUpdateResponse parses an HTTP response from a CollectionUpdateWithResponse call +func ParseCollectionUpdateResponse(rsp *http.Response) (*CollectionUpdateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AssetGetResponse{ + response := &CollectionUpdateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Collection + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6292,24 +8830,22 @@ func ParseAssetGetResponse(rsp *http.Response) (*AssetGetResponse, error) { return response, nil } -// ParseAuthProviderListResponse parses an HTTP response from a AuthProviderListWithResponse call -func ParseAuthProviderListResponse(rsp *http.Response) (*AuthProviderListResponse, error) { +// ParseCollectionRemovePostResponse parses an HTTP response from a CollectionRemovePostWithResponse call +func ParseCollectionRemovePostResponse(rsp *http.Response) (*CollectionRemovePostResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthProviderListResponse{ + response := &CollectionRemovePostResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Providers AuthProviderList `json:"providers"` - } + var dest Collection if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6327,20 +8863,27 @@ func ParseAuthProviderListResponse(rsp *http.Response) (*AuthProviderListRespons return response, nil } -// ParseAuthProviderLogoutResponse parses an HTTP response from a AuthProviderLogoutWithResponse call -func ParseAuthProviderLogoutResponse(rsp *http.Response) (*AuthProviderLogoutResponse, error) { +// ParseCollectionAddPostResponse parses an HTTP response from a CollectionAddPostWithResponse call +func ParseCollectionAddPostResponse(rsp *http.Response) (*CollectionAddPostResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthProviderLogoutResponse{ + response := &CollectionAddPostResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Collection + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6353,22 +8896,22 @@ func ParseAuthProviderLogoutResponse(rsp *http.Response) (*AuthProviderLogoutRes return response, nil } -// ParseOAuthProviderCallbackResponse parses an HTTP response from a OAuthProviderCallbackWithResponse call -func ParseOAuthProviderCallbackResponse(rsp *http.Response) (*OAuthProviderCallbackResponse, error) { +// ParseGetInfoResponse parses an HTTP response from a GetInfoWithResponse call +func ParseGetInfoResponse(rsp *http.Response) (*GetInfoResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &OAuthProviderCallbackResponse{ + response := &GetInfoResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + var dest Info if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6386,27 +8929,46 @@ func ParseOAuthProviderCallbackResponse(rsp *http.Response) (*OAuthProviderCallb return response, nil } -// ParseAuthPasswordSigninResponse parses an HTTP response from a AuthPasswordSigninWithResponse call -func ParseAuthPasswordSigninResponse(rsp *http.Response) (*AuthPasswordSigninResponse, error) { +// ParseIconUploadResponse parses an HTTP response from a IconUploadWithResponse call +func ParseIconUploadResponse(rsp *http.Response) (*IconUploadResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthPasswordSigninResponse{ + response := &IconUploadResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseIconGetResponse parses an HTTP response from a IconGetWithResponse call +func ParseIconGetResponse(rsp *http.Response) (*IconGetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IconGetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6419,22 +8981,27 @@ func ParseAuthPasswordSigninResponse(rsp *http.Response) (*AuthPasswordSigninRes return response, nil } -// ParseAuthPasswordSignupResponse parses an HTTP response from a AuthPasswordSignupWithResponse call -func ParseAuthPasswordSignupResponse(rsp *http.Response) (*AuthPasswordSignupResponse, error) { +// ParseItemListResponse parses an HTTP response from a ItemListWithResponse call +func ParseItemListResponse(rsp *http.Response) (*ItemListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthPasswordSignupResponse{ + response := &ItemListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + var dest struct { + // Clusters A list of items where each item includes all the information about its + // parent cluster too. For use with APIs that want to provide a list of + // items that may be part of different clusters. + Clusters ItemList `json:"clusters"` + } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6452,22 +9019,22 @@ func ParseAuthPasswordSignupResponse(rsp *http.Response) (*AuthPasswordSignupRes return response, nil } -// ParsePhoneRequestCodeResponse parses an HTTP response from a PhoneRequestCodeWithResponse call -func ParsePhoneRequestCodeResponse(rsp *http.Response) (*PhoneRequestCodeResponse, error) { +// ParseItemCreateResponse parses an HTTP response from a ItemCreateWithResponse call +func ParseItemCreateResponse(rsp *http.Response) (*ItemCreateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PhoneRequestCodeResponse{ + response := &ItemCreateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + var dest Item if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6485,22 +9052,22 @@ func ParsePhoneRequestCodeResponse(rsp *http.Response) (*PhoneRequestCodeRespons return response, nil } -// ParsePhoneSubmitCodeResponse parses an HTTP response from a PhoneSubmitCodeWithResponse call -func ParsePhoneSubmitCodeResponse(rsp *http.Response) (*PhoneSubmitCodeResponse, error) { +// ParseItemGetResponse parses an HTTP response from a ItemGetWithResponse call +func ParseItemGetResponse(rsp *http.Response) (*ItemGetResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PhoneSubmitCodeResponse{ + response := &ItemGetResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + var dest ItemWithParents if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6518,22 +9085,22 @@ func ParsePhoneSubmitCodeResponse(rsp *http.Response) (*PhoneSubmitCodeResponse, return response, nil } -// ParseWebAuthnMakeAssertionResponse parses an HTTP response from a WebAuthnMakeAssertionWithResponse call -func ParseWebAuthnMakeAssertionResponse(rsp *http.Response) (*WebAuthnMakeAssertionResponse, error) { +// ParseItemUpdateResponse parses an HTTP response from a ItemUpdateWithResponse call +func ParseItemUpdateResponse(rsp *http.Response) (*ItemUpdateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &WebAuthnMakeAssertionResponse{ + response := &ItemUpdateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess + var dest Item if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6551,22 +9118,22 @@ func ParseWebAuthnMakeAssertionResponse(rsp *http.Response) (*WebAuthnMakeAssert return response, nil } -// ParseWebAuthnGetAssertionResponse parses an HTTP response from a WebAuthnGetAssertionWithResponse call -func ParseWebAuthnGetAssertionResponse(rsp *http.Response) (*WebAuthnGetAssertionResponse, error) { +// ParsePostSearchResponse parses an HTTP response from a PostSearchWithResponse call +func ParsePostSearchResponse(rsp *http.Response) (*PostSearchResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &WebAuthnGetAssertionResponse{ + response := &PostSearchResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CredentialRequestOptions + var dest PostSearchResults if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6584,27 +9151,20 @@ func ParseWebAuthnGetAssertionResponse(rsp *http.Response) (*WebAuthnGetAssertio return response, nil } -// ParseWebAuthnMakeCredentialResponse parses an HTTP response from a WebAuthnMakeCredentialWithResponse call -func ParseWebAuthnMakeCredentialResponse(rsp *http.Response) (*WebAuthnMakeCredentialResponse, error) { +// ParsePostDeleteResponse parses an HTTP response from a PostDeleteWithResponse call +func ParsePostDeleteResponse(rsp *http.Response) (*PostDeleteResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &WebAuthnMakeCredentialResponse{ + response := &PostDeleteResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuthSuccess - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6617,22 +9177,22 @@ func ParseWebAuthnMakeCredentialResponse(rsp *http.Response) (*WebAuthnMakeCrede return response, nil } -// ParseWebAuthnRequestCredentialResponse parses an HTTP response from a WebAuthnRequestCredentialWithResponse call -func ParseWebAuthnRequestCredentialResponse(rsp *http.Response) (*WebAuthnRequestCredentialResponse, error) { +// ParsePostUpdateResponse parses an HTTP response from a PostUpdateWithResponse call +func ParsePostUpdateResponse(rsp *http.Response) (*PostUpdateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &WebAuthnRequestCredentialResponse{ + response := &PostUpdateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest WebAuthnPublicKeyCreationOptions + var dest PostProps if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6650,22 +9210,22 @@ func ParseWebAuthnRequestCredentialResponse(rsp *http.Response) (*WebAuthnReques return response, nil } -// ParseCategoryListResponse parses an HTTP response from a CategoryListWithResponse call -func ParseCategoryListResponse(rsp *http.Response) (*CategoryListResponse, error) { +// ParsePostReactAddResponse parses an HTTP response from a PostReactAddWithResponse call +func ParsePostReactAddResponse(rsp *http.Response) (*PostReactAddResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CategoryListResponse{ + response := &PostReactAddResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CategoryList + var dest React if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6683,22 +9243,22 @@ func ParseCategoryListResponse(rsp *http.Response) (*CategoryListResponse, error return response, nil } -// ParseCategoryUpdateOrderResponse parses an HTTP response from a CategoryUpdateOrderWithResponse call -func ParseCategoryUpdateOrderResponse(rsp *http.Response) (*CategoryUpdateOrderResponse, error) { +// ParseProfileGetResponse parses an HTTP response from a ProfileGetWithResponse call +func ParseProfileGetResponse(rsp *http.Response) (*ProfileGetResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CategoryUpdateOrderResponse{ + response := &ProfileGetResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CategoryList + var dest PublicProfile if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6716,22 +9276,24 @@ func ParseCategoryUpdateOrderResponse(rsp *http.Response) (*CategoryUpdateOrderR return response, nil } -// ParseCategoryCreateResponse parses an HTTP response from a CategoryCreateWithResponse call -func ParseCategoryCreateResponse(rsp *http.Response) (*CategoryCreateResponse, error) { +// ParseThreadListResponse parses an HTTP response from a ThreadListWithResponse call +func ParseThreadListResponse(rsp *http.Response) (*ThreadListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CategoryCreateResponse{ + response := &ThreadListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Category + var dest struct { + Threads ThreadList `json:"threads"` + } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6749,22 +9311,22 @@ func ParseCategoryCreateResponse(rsp *http.Response) (*CategoryCreateResponse, e return response, nil } -// ParseCategoryUpdateResponse parses an HTTP response from a CategoryUpdateWithResponse call -func ParseCategoryUpdateResponse(rsp *http.Response) (*CategoryUpdateResponse, error) { +// ParseThreadCreateResponse parses an HTTP response from a ThreadCreateWithResponse call +func ParseThreadCreateResponse(rsp *http.Response) (*ThreadCreateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CategoryUpdateResponse{ + response := &ThreadCreateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Category + var dest Thread if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6782,29 +9344,20 @@ func ParseCategoryUpdateResponse(rsp *http.Response) (*CategoryUpdateResponse, e return response, nil } -// ParseCollectionListResponse parses an HTTP response from a CollectionListWithResponse call -func ParseCollectionListResponse(rsp *http.Response) (*CollectionListResponse, error) { +// ParseThreadDeleteResponse parses an HTTP response from a ThreadDeleteWithResponse call +func ParseThreadDeleteResponse(rsp *http.Response) (*ThreadDeleteResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CollectionListResponse{ + response := &ThreadDeleteResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Collections CollectionList `json:"collections"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest APIError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -6817,22 +9370,22 @@ func ParseCollectionListResponse(rsp *http.Response) (*CollectionListResponse, e return response, nil } -// ParseCollectionCreateResponse parses an HTTP response from a CollectionCreateWithResponse call -func ParseCollectionCreateResponse(rsp *http.Response) (*CollectionCreateResponse, error) { +// ParseThreadGetResponse parses an HTTP response from a ThreadGetWithResponse call +func ParseThreadGetResponse(rsp *http.Response) (*ThreadGetResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CollectionCreateResponse{ + response := &ThreadGetResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection + var dest Thread if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6850,22 +9403,22 @@ func ParseCollectionCreateResponse(rsp *http.Response) (*CollectionCreateRespons return response, nil } -// ParseCollectionGetResponse parses an HTTP response from a CollectionGetWithResponse call -func ParseCollectionGetResponse(rsp *http.Response) (*CollectionGetResponse, error) { +// ParseThreadUpdateResponse parses an HTTP response from a ThreadUpdateWithResponse call +func ParseThreadUpdateResponse(rsp *http.Response) (*ThreadUpdateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CollectionGetResponse{ + response := &ThreadUpdateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CollectionWithItems + var dest Thread if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6883,22 +9436,22 @@ func ParseCollectionGetResponse(rsp *http.Response) (*CollectionGetResponse, err return response, nil } -// ParseCollectionUpdateResponse parses an HTTP response from a CollectionUpdateWithResponse call -func ParseCollectionUpdateResponse(rsp *http.Response) (*CollectionUpdateResponse, error) { +// ParsePostCreateResponse parses an HTTP response from a PostCreateWithResponse call +func ParsePostCreateResponse(rsp *http.Response) (*PostCreateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CollectionUpdateResponse{ + response := &PostCreateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection + var dest PostProps if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -6916,743 +9469,995 @@ func ParseCollectionUpdateResponse(rsp *http.Response) (*CollectionUpdateRespons return response, nil } -// ParseCollectionRemovePostResponse parses an HTTP response from a CollectionRemovePostWithResponse call -func ParseCollectionRemovePostResponse(rsp *http.Response) (*CollectionRemovePostResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// ParseGetVersionResponse parses an HTTP response from a GetVersionWithResponse call +func ParseGetVersionResponse(rsp *http.Response) (*GetVersionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVersionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ServerInterface represents all server handlers. +type ServerInterface interface { + // Get the OpenAPI 3.0 specification as JSON. + // (GET /openapi.json) + GetSpec(ctx echo.Context) error + + // (GET /v1/accounts) + AccountGet(ctx echo.Context) error + + // (PATCH /v1/accounts) + AccountUpdate(ctx echo.Context) error + + // (GET /v1/accounts/self/auth-methods) + AccountAuthProviderList(ctx echo.Context) error + + // (POST /v1/accounts/self/avatar) + AccountSetAvatar(ctx echo.Context, params AccountSetAvatarParams) error + + // (GET /v1/accounts/{account_handle}/avatar) + AccountGetAvatar(ctx echo.Context, accountHandle AccountHandleParam) error + + // (PATCH /v1/admin) + AdminSettingsUpdate(ctx echo.Context) error + + // (POST /v1/assets) + AssetUpload(ctx echo.Context, params AssetUploadParams) error + + // (GET /v1/assets/{id}) + AssetGet(ctx echo.Context, id AssetPath) error + + // (GET /v1/auth) + AuthProviderList(ctx echo.Context) error + + // (GET /v1/auth/logout) + AuthProviderLogout(ctx echo.Context) error + + // (POST /v1/auth/oauth/{oauth_provider}/callback) + OAuthProviderCallback(ctx echo.Context, oauthProvider OAuthProvider) error + + // (POST /v1/auth/password/signin) + AuthPasswordSignin(ctx echo.Context) error + + // (POST /v1/auth/password/signup) + AuthPasswordSignup(ctx echo.Context) error + + // (POST /v1/auth/phone) + PhoneRequestCode(ctx echo.Context) error + + // (PUT /v1/auth/phone/{account_handle}) + PhoneSubmitCode(ctx echo.Context, accountHandle AccountHandleParam) error + + // (POST /v1/auth/webauthn/assert) + WebAuthnMakeAssertion(ctx echo.Context) error + + // (GET /v1/auth/webauthn/assert/{account_handle}) + WebAuthnGetAssertion(ctx echo.Context, accountHandle AccountHandleParam) error + + // (POST /v1/auth/webauthn/make) + WebAuthnMakeCredential(ctx echo.Context) error + + // (GET /v1/auth/webauthn/make/{account_handle}) + WebAuthnRequestCredential(ctx echo.Context, accountHandle AccountHandleParam) error + + // (GET /v1/categories) + CategoryList(ctx echo.Context) error + + // (PATCH /v1/categories) + CategoryUpdateOrder(ctx echo.Context) error + + // (POST /v1/categories) + CategoryCreate(ctx echo.Context) error + + // (PATCH /v1/categories/{category_id}) + CategoryUpdate(ctx echo.Context, categoryId CategoryIDParam) error + + // (GET /v1/clusters) + ClusterList(ctx echo.Context) error + + // (POST /v1/clusters) + ClusterCreate(ctx echo.Context) error + + // (GET /v1/clusters/{cluster_slug}) + ClusterGet(ctx echo.Context, clusterSlug ClusterSlugParam) error + + // (PATCH /v1/clusters/{cluster_slug}) + ClusterUpdate(ctx echo.Context, clusterSlug ClusterSlugParam) error + + // (DELETE /v1/clusters/{cluster_slug}/clusters/{cluster_slug_child}) + ClusterRemoveCluster(ctx echo.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) error + + // (PUT /v1/clusters/{cluster_slug}/clusters/{cluster_slug_child}) + ClusterAddCluster(ctx echo.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) error + + // (DELETE /v1/clusters/{cluster_slug}/items/{item_slug}) + ClusterRemoveItem(ctx echo.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) error + + // (PUT /v1/clusters/{cluster_slug}/items/{item_slug}) + ClusterAddItem(ctx echo.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) error + + // (GET /v1/collections) + CollectionList(ctx echo.Context) error + + // (POST /v1/collections) + CollectionCreate(ctx echo.Context) error + + // (GET /v1/collections/{collection_id}) + CollectionGet(ctx echo.Context, collectionId CollectionIDParam) error + + // (PATCH /v1/collections/{collection_id}) + CollectionUpdate(ctx echo.Context, collectionId CollectionIDParam) error + + // (DELETE /v1/collections/{collection_id}/items/{post_id}) + CollectionRemovePost(ctx echo.Context, collectionId CollectionIDParam, postId PostIDParam) error + + // (PUT /v1/collections/{collection_id}/items/{post_id}) + CollectionAddPost(ctx echo.Context, collectionId CollectionIDParam, postId PostIDParam) error + + // (GET /v1/info) + GetInfo(ctx echo.Context) error + + // (POST /v1/info/icon) + IconUpload(ctx echo.Context, params IconUploadParams) error + + // (GET /v1/info/icon/{icon_size}) + IconGet(ctx echo.Context, iconSize IconGetParamsIconSize) error + + // (GET /v1/items) + ItemList(ctx echo.Context) error + + // (POST /v1/items) + ItemCreate(ctx echo.Context) error + + // (GET /v1/items/{item_slug}) + ItemGet(ctx echo.Context, itemSlug ItemSlugParam) error + + // (PATCH /v1/items/{item_slug}) + ItemUpdate(ctx echo.Context, itemSlug ItemSlugParam) error + + // (GET /v1/posts/search) + PostSearch(ctx echo.Context, params PostSearchParams) error + + // (DELETE /v1/posts/{post_id}) + PostDelete(ctx echo.Context, postId PostIDParam) error + + // (PATCH /v1/posts/{post_id}) + PostUpdate(ctx echo.Context, postId PostIDParam) error + + // (PUT /v1/posts/{post_id}/reacts) + PostReactAdd(ctx echo.Context, postId PostIDParam) error + + // (GET /v1/profiles/{account_handle}) + ProfileGet(ctx echo.Context, accountHandle AccountHandleParam) error - response := &CollectionRemovePostResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + // (GET /v1/threads) + ThreadList(ctx echo.Context, params ThreadListParams) error - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // (POST /v1/threads) + ThreadCreate(ctx echo.Context) error - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // (DELETE /v1/threads/{thread_mark}) + ThreadDelete(ctx echo.Context, threadMark ThreadMarkParam) error + // Get information about a thread and the posts within the thread. + // (GET /v1/threads/{thread_mark}) + ThreadGet(ctx echo.Context, threadMark ThreadMarkParam) error - } + // (PATCH /v1/threads/{thread_mark}) + ThreadUpdate(ctx echo.Context, threadMark ThreadMarkParam) error - return response, nil + // (POST /v1/threads/{thread_mark}/posts) + PostCreate(ctx echo.Context, threadMark ThreadMarkParam) error + // Get the software version string. + // (GET /version) + GetVersion(ctx echo.Context) error } -// ParseCollectionAddPostResponse parses an HTTP response from a CollectionAddPostWithResponse call -func ParseCollectionAddPostResponse(rsp *http.Response) (*CollectionAddPostResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// ServerInterfaceWrapper converts echo contexts to parameters. +type ServerInterfaceWrapper struct { + Handler ServerInterface +} - response := &CollectionAddPostResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } +// GetSpec converts echo context to params. +func (w *ServerInterfaceWrapper) GetSpec(ctx echo.Context) error { + var err error - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Collection - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.GetSpec(ctx) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// AccountGet converts echo context to params. +func (w *ServerInterfaceWrapper) AccountGet(ctx echo.Context) error { + var err error - } + ctx.Set(BrowserScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AccountGet(ctx) + return err } -// ParseGetInfoResponse parses an HTTP response from a GetInfoWithResponse call -func ParseGetInfoResponse(rsp *http.Response) (*GetInfoResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetInfoResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } +// AccountUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) AccountUpdate(ctx echo.Context) error { + var err error - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Info - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + ctx.Set(BrowserScopes, []string{""}) - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AccountUpdate(ctx) + return err +} - } +// AccountAuthProviderList converts echo context to params. +func (w *ServerInterfaceWrapper) AccountAuthProviderList(ctx echo.Context) error { + var err error - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AccountAuthProviderList(ctx) + return err } -// ParseIconUploadResponse parses an HTTP response from a IconUploadWithResponse call -func ParseIconUploadResponse(rsp *http.Response) (*IconUploadResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// AccountSetAvatar converts echo context to params. +func (w *ServerInterfaceWrapper) AccountSetAvatar(ctx echo.Context) error { + var err error - response := &IconUploadResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err + // Parameter object where we will unmarshal all parameters from the context + var params AccountSetAvatarParams + + headers := ctx.Request().Header + // ------------- Required header parameter "Content-Length" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { + var ContentLength ContentLength + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) } - response.JSONDefault = &dest + err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) + } + + params.ContentLength = ContentLength + } else { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) } - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AccountSetAvatar(ctx, params) + return err } -// ParseIconGetResponse parses an HTTP response from a IconGetWithResponse call -func ParseIconGetResponse(rsp *http.Response) (*IconGetResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// AccountGetAvatar converts echo context to params. +func (w *ServerInterfaceWrapper) AccountGetAvatar(ctx echo.Context) error { + var err error + // ------------- Path parameter "account_handle" ------------- + var accountHandle AccountHandleParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) } - response := &IconGetResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AccountGetAvatar(ctx, accountHandle) + return err +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// AdminSettingsUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) AdminSettingsUpdate(ctx echo.Context) error { + var err error - } + ctx.Set(BrowserScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AdminSettingsUpdate(ctx) + return err } -// ParsePostSearchResponse parses an HTTP response from a PostSearchWithResponse call -func ParsePostSearchResponse(rsp *http.Response) (*PostSearchResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// AssetUpload converts echo context to params. +func (w *ServerInterfaceWrapper) AssetUpload(ctx echo.Context) error { + var err error - response := &PostSearchResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest PostSearchResults - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err + // Parameter object where we will unmarshal all parameters from the context + var params AssetUploadParams + + headers := ctx.Request().Header + // ------------- Required header parameter "Content-Length" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { + var ContentLength ContentLength + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err + err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) } - response.JSONDefault = &dest + params.ContentLength = ContentLength + } else { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) + } + + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AssetUpload(ctx, params) + return err +} + +// AssetGet converts echo context to params. +func (w *ServerInterfaceWrapper) AssetGet(ctx echo.Context) error { + var err error + // ------------- Path parameter "id" ------------- + var id AssetPath + + err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) } - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AssetGet(ctx, id) + return err } -// ParsePostDeleteResponse parses an HTTP response from a PostDeleteWithResponse call -func ParsePostDeleteResponse(rsp *http.Response) (*PostDeleteResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// AuthProviderList converts echo context to params. +func (w *ServerInterfaceWrapper) AuthProviderList(ctx echo.Context) error { + var err error - response := &PostDeleteResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AuthProviderList(ctx) + return err +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// AuthProviderLogout converts echo context to params. +func (w *ServerInterfaceWrapper) AuthProviderLogout(ctx echo.Context) error { + var err error - } + ctx.Set(BrowserScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AuthProviderLogout(ctx) + return err } -// ParsePostUpdateResponse parses an HTTP response from a PostUpdateWithResponse call -func ParsePostUpdateResponse(rsp *http.Response) (*PostUpdateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// OAuthProviderCallback converts echo context to params. +func (w *ServerInterfaceWrapper) OAuthProviderCallback(ctx echo.Context) error { + var err error + // ------------- Path parameter "oauth_provider" ------------- + var oauthProvider OAuthProvider + + err = runtime.BindStyledParameterWithLocation("simple", false, "oauth_provider", runtime.ParamLocationPath, ctx.Param("oauth_provider"), &oauthProvider) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter oauth_provider: %s", err)) } - response := &PostUpdateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.OAuthProviderCallback(ctx, oauthProvider) + return err +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest PostProps - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest +// AuthPasswordSignin converts echo context to params. +func (w *ServerInterfaceWrapper) AuthPasswordSignin(ctx echo.Context) error { + var err error - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AuthPasswordSignin(ctx) + return err +} - } +// AuthPasswordSignup converts echo context to params. +func (w *ServerInterfaceWrapper) AuthPasswordSignup(ctx echo.Context) error { + var err error - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.AuthPasswordSignup(ctx) + return err } -// ParsePostReactAddResponse parses an HTTP response from a PostReactAddWithResponse call -func ParsePostReactAddResponse(rsp *http.Response) (*PostReactAddResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// PhoneRequestCode converts echo context to params. +func (w *ServerInterfaceWrapper) PhoneRequestCode(ctx echo.Context) error { + var err error - response := &PostReactAddResponse{ - Body: bodyBytes, - HTTPResponse: rsp, + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.PhoneRequestCode(ctx) + return err +} + +// PhoneSubmitCode converts echo context to params. +func (w *ServerInterfaceWrapper) PhoneSubmitCode(ctx echo.Context) error { + var err error + // ------------- Path parameter "account_handle" ------------- + var accountHandle AccountHandleParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) } - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest React - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.PhoneSubmitCode(ctx, accountHandle) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// WebAuthnMakeAssertion converts echo context to params. +func (w *ServerInterfaceWrapper) WebAuthnMakeAssertion(ctx echo.Context) error { + var err error - } + ctx.Set(WebauthnScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.WebAuthnMakeAssertion(ctx) + return err } -// ParseProfileGetResponse parses an HTTP response from a ProfileGetWithResponse call -func ParseProfileGetResponse(rsp *http.Response) (*ProfileGetResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// WebAuthnGetAssertion converts echo context to params. +func (w *ServerInterfaceWrapper) WebAuthnGetAssertion(ctx echo.Context) error { + var err error + // ------------- Path parameter "account_handle" ------------- + var accountHandle AccountHandleParam - response := &ProfileGetResponse{ - Body: bodyBytes, - HTTPResponse: rsp, + err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) } - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest PublicProfile - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.WebAuthnGetAssertion(ctx, accountHandle) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// WebAuthnMakeCredential converts echo context to params. +func (w *ServerInterfaceWrapper) WebAuthnMakeCredential(ctx echo.Context) error { + var err error - } + ctx.Set(WebauthnScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.WebAuthnMakeCredential(ctx) + return err } -// ParseThreadListResponse parses an HTTP response from a ThreadListWithResponse call -func ParseThreadListResponse(rsp *http.Response) (*ThreadListResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// WebAuthnRequestCredential converts echo context to params. +func (w *ServerInterfaceWrapper) WebAuthnRequestCredential(ctx echo.Context) error { + var err error + // ------------- Path parameter "account_handle" ------------- + var accountHandle AccountHandleParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) } - response := &ThreadListResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.WebAuthnRequestCredential(ctx, accountHandle) + return err +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Threads ThreadList `json:"threads"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest +// CategoryList converts echo context to params. +func (w *ServerInterfaceWrapper) CategoryList(ctx echo.Context) error { + var err error - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CategoryList(ctx) + return err +} - } +// CategoryUpdateOrder converts echo context to params. +func (w *ServerInterfaceWrapper) CategoryUpdateOrder(ctx echo.Context) error { + var err error - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CategoryUpdateOrder(ctx) + return err +} + +// CategoryCreate converts echo context to params. +func (w *ServerInterfaceWrapper) CategoryCreate(ctx echo.Context) error { + var err error + + ctx.Set(BrowserScopes, []string{""}) + + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CategoryCreate(ctx) + return err } -// ParseThreadCreateResponse parses an HTTP response from a ThreadCreateWithResponse call -func ParseThreadCreateResponse(rsp *http.Response) (*ThreadCreateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// CategoryUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) CategoryUpdate(ctx echo.Context) error { + var err error + // ------------- Path parameter "category_id" ------------- + var categoryId CategoryIDParam - response := &ThreadCreateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, + err = runtime.BindStyledParameterWithLocation("simple", false, "category_id", runtime.ParamLocationPath, ctx.Param("category_id"), &categoryId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter category_id: %s", err)) } - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Thread - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + ctx.Set(BrowserScopes, []string{""}) - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CategoryUpdate(ctx, categoryId) + return err +} - } +// ClusterList converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterList(ctx echo.Context) error { + var err error - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterList(ctx) + return err } -// ParseThreadDeleteResponse parses an HTTP response from a ThreadDeleteWithResponse call -func ParseThreadDeleteResponse(rsp *http.Response) (*ThreadDeleteResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } +// ClusterCreate converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterCreate(ctx echo.Context) error { + var err error - response := &ThreadDeleteResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterCreate(ctx) + return err +} + +// ClusterGet converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterGet(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) } - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterGet(ctx, clusterSlug) + return err } -// ParseThreadGetResponse parses an HTTP response from a ThreadGetWithResponse call -func ParseThreadGetResponse(rsp *http.Response) (*ThreadGetResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ClusterUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterUpdate(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) } - response := &ThreadGetResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Thread - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterUpdate(ctx, clusterSlug) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// ClusterRemoveCluster converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterRemoveCluster(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) } - return response, nil -} + // ------------- Path parameter "cluster_slug_child" ------------- + var clusterSlugChild ClusterSlugChildParam -// ParseThreadUpdateResponse parses an HTTP response from a ThreadUpdateWithResponse call -func ParseThreadUpdateResponse(rsp *http.Response) (*ThreadUpdateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug_child", runtime.ParamLocationPath, ctx.Param("cluster_slug_child"), &clusterSlugChild) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug_child: %s", err)) } - response := &ThreadUpdateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Thread - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterRemoveCluster(ctx, clusterSlug, clusterSlugChild) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// ClusterAddCluster converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterAddCluster(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) } - return response, nil -} + // ------------- Path parameter "cluster_slug_child" ------------- + var clusterSlugChild ClusterSlugChildParam -// ParsePostCreateResponse parses an HTTP response from a PostCreateWithResponse call -func ParsePostCreateResponse(rsp *http.Response) (*PostCreateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug_child", runtime.ParamLocationPath, ctx.Param("cluster_slug_child"), &clusterSlugChild) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug_child: %s", err)) } - response := &PostCreateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest PostProps - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterAddCluster(ctx, clusterSlug, clusterSlugChild) + return err +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest APIError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// ClusterRemoveItem converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterRemoveItem(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) } - return response, nil -} + // ------------- Path parameter "item_slug" ------------- + var itemSlug ItemSlugParam -// ParseGetVersionResponse parses an HTTP response from a GetVersionWithResponse call -func ParseGetVersionResponse(rsp *http.Response) (*GetVersionResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() + err = runtime.BindStyledParameterWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, ctx.Param("item_slug"), &itemSlug) if err != nil { - return nil, err + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter item_slug: %s", err)) } - response := &GetVersionResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } + ctx.Set(BrowserScopes, []string{""}) - return response, nil + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterRemoveItem(ctx, clusterSlug, itemSlug) + return err } -// ServerInterface represents all server handlers. -type ServerInterface interface { - // Get the OpenAPI 3.0 specification as JSON. - // (GET /openapi.json) - GetSpec(ctx echo.Context) error +// ClusterAddItem converts echo context to params. +func (w *ServerInterfaceWrapper) ClusterAddItem(ctx echo.Context) error { + var err error + // ------------- Path parameter "cluster_slug" ------------- + var clusterSlug ClusterSlugParam - // (GET /v1/accounts) - AccountGet(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "cluster_slug", runtime.ParamLocationPath, ctx.Param("cluster_slug"), &clusterSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter cluster_slug: %s", err)) + } - // (PATCH /v1/accounts) - AccountUpdate(ctx echo.Context) error + // ------------- Path parameter "item_slug" ------------- + var itemSlug ItemSlugParam - // (GET /v1/accounts/self/auth-methods) - AccountAuthProviderList(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, ctx.Param("item_slug"), &itemSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter item_slug: %s", err)) + } - // (POST /v1/accounts/self/avatar) - AccountSetAvatar(ctx echo.Context, params AccountSetAvatarParams) error + ctx.Set(BrowserScopes, []string{""}) - // (GET /v1/accounts/{account_handle}/avatar) - AccountGetAvatar(ctx echo.Context, accountHandle AccountHandleParam) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ClusterAddItem(ctx, clusterSlug, itemSlug) + return err +} - // (PATCH /v1/admin) - AdminSettingsUpdate(ctx echo.Context) error +// CollectionList converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionList(ctx echo.Context) error { + var err error - // (POST /v1/assets) - AssetUpload(ctx echo.Context, params AssetUploadParams) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionList(ctx) + return err +} - // (GET /v1/assets/{id}) - AssetGet(ctx echo.Context, id AssetPath) error +// CollectionCreate converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionCreate(ctx echo.Context) error { + var err error - // (GET /v1/auth) - AuthProviderList(ctx echo.Context) error + ctx.Set(BrowserScopes, []string{""}) - // (GET /v1/auth/logout) - AuthProviderLogout(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionCreate(ctx) + return err +} - // (POST /v1/auth/oauth/{oauth_provider}/callback) - OAuthProviderCallback(ctx echo.Context, oauthProvider OAuthProvider) error +// CollectionGet converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionGet(ctx echo.Context) error { + var err error + // ------------- Path parameter "collection_id" ------------- + var collectionId CollectionIDParam - // (POST /v1/auth/password/signin) - AuthPasswordSignin(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) + } - // (POST /v1/auth/password/signup) - AuthPasswordSignup(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionGet(ctx, collectionId) + return err +} - // (POST /v1/auth/phone) - PhoneRequestCode(ctx echo.Context) error +// CollectionUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionUpdate(ctx echo.Context) error { + var err error + // ------------- Path parameter "collection_id" ------------- + var collectionId CollectionIDParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) + } - // (PUT /v1/auth/phone/{account_handle}) - PhoneSubmitCode(ctx echo.Context, accountHandle AccountHandleParam) error + ctx.Set(BrowserScopes, []string{""}) - // (POST /v1/auth/webauthn/assert) - WebAuthnMakeAssertion(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionUpdate(ctx, collectionId) + return err +} - // (GET /v1/auth/webauthn/assert/{account_handle}) - WebAuthnGetAssertion(ctx echo.Context, accountHandle AccountHandleParam) error +// CollectionRemovePost converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionRemovePost(ctx echo.Context) error { + var err error + // ------------- Path parameter "collection_id" ------------- + var collectionId CollectionIDParam - // (POST /v1/auth/webauthn/make) - WebAuthnMakeCredential(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) + } - // (GET /v1/auth/webauthn/make/{account_handle}) - WebAuthnRequestCredential(ctx echo.Context, accountHandle AccountHandleParam) error + // ------------- Path parameter "post_id" ------------- + var postId PostIDParam - // (GET /v1/categories) - CategoryList(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) + } - // (PATCH /v1/categories) - CategoryUpdateOrder(ctx echo.Context) error + ctx.Set(BrowserScopes, []string{""}) - // (POST /v1/categories) - CategoryCreate(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionRemovePost(ctx, collectionId, postId) + return err +} - // (PATCH /v1/categories/{category_id}) - CategoryUpdate(ctx echo.Context, categoryId CategoryIDParam) error +// CollectionAddPost converts echo context to params. +func (w *ServerInterfaceWrapper) CollectionAddPost(ctx echo.Context) error { + var err error + // ------------- Path parameter "collection_id" ------------- + var collectionId CollectionIDParam - // (GET /v1/collections) - CollectionList(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) + } - // (POST /v1/collections) - CollectionCreate(ctx echo.Context) error + // ------------- Path parameter "post_id" ------------- + var postId PostIDParam - // (GET /v1/collections/{collection_id}) - CollectionGet(ctx echo.Context, collectionId CollectionIDParam) error + err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) + } - // (PATCH /v1/collections/{collection_id}) - CollectionUpdate(ctx echo.Context, collectionId CollectionIDParam) error + ctx.Set(BrowserScopes, []string{""}) - // (DELETE /v1/collections/{collection_id}/items/{post_id}) - CollectionRemovePost(ctx echo.Context, collectionId CollectionIDParam, postId PostIDParam) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.CollectionAddPost(ctx, collectionId, postId) + return err +} - // (PUT /v1/collections/{collection_id}/items/{post_id}) - CollectionAddPost(ctx echo.Context, collectionId CollectionIDParam, postId PostIDParam) error +// GetInfo converts echo context to params. +func (w *ServerInterfaceWrapper) GetInfo(ctx echo.Context) error { + var err error - // (GET /v1/info) - GetInfo(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.GetInfo(ctx) + return err +} - // (POST /v1/info/icon) - IconUpload(ctx echo.Context, params IconUploadParams) error +// IconUpload converts echo context to params. +func (w *ServerInterfaceWrapper) IconUpload(ctx echo.Context) error { + var err error - // (GET /v1/info/icon/{icon_size}) - IconGet(ctx echo.Context, iconSize IconGetParamsIconSize) error + ctx.Set(BrowserScopes, []string{""}) - // (GET /v1/posts/search) - PostSearch(ctx echo.Context, params PostSearchParams) error + // Parameter object where we will unmarshal all parameters from the context + var params IconUploadParams - // (DELETE /v1/posts/{post_id}) - PostDelete(ctx echo.Context, postId PostIDParam) error + headers := ctx.Request().Header + // ------------- Required header parameter "Content-Length" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { + var ContentLength ContentLength + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) + } - // (PATCH /v1/posts/{post_id}) - PostUpdate(ctx echo.Context, postId PostIDParam) error + err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) + } - // (PUT /v1/posts/{post_id}/reacts) - PostReactAdd(ctx echo.Context, postId PostIDParam) error + params.ContentLength = ContentLength + } else { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) + } - // (GET /v1/profiles/{account_handle}) - ProfileGet(ctx echo.Context, accountHandle AccountHandleParam) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.IconUpload(ctx, params) + return err +} - // (GET /v1/threads) - ThreadList(ctx echo.Context, params ThreadListParams) error +// IconGet converts echo context to params. +func (w *ServerInterfaceWrapper) IconGet(ctx echo.Context) error { + var err error + // ------------- Path parameter "icon_size" ------------- + var iconSize IconGetParamsIconSize - // (POST /v1/threads) - ThreadCreate(ctx echo.Context) error + err = runtime.BindStyledParameterWithLocation("simple", false, "icon_size", runtime.ParamLocationPath, ctx.Param("icon_size"), &iconSize) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter icon_size: %s", err)) + } - // (DELETE /v1/threads/{thread_mark}) - ThreadDelete(ctx echo.Context, threadMark ThreadMarkParam) error - // Get information about a thread and the posts within the thread. - // (GET /v1/threads/{thread_mark}) - ThreadGet(ctx echo.Context, threadMark ThreadMarkParam) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.IconGet(ctx, iconSize) + return err +} - // (PATCH /v1/threads/{thread_mark}) - ThreadUpdate(ctx echo.Context, threadMark ThreadMarkParam) error +// ItemList converts echo context to params. +func (w *ServerInterfaceWrapper) ItemList(ctx echo.Context) error { + var err error - // (POST /v1/threads/{thread_mark}/posts) - PostCreate(ctx echo.Context, threadMark ThreadMarkParam) error - // Get the software version string. - // (GET /version) - GetVersion(ctx echo.Context) error + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ItemList(ctx) + return err } -// ServerInterfaceWrapper converts echo contexts to parameters. -type ServerInterfaceWrapper struct { - Handler ServerInterface +// ItemCreate converts echo context to params. +func (w *ServerInterfaceWrapper) ItemCreate(ctx echo.Context) error { + var err error + + ctx.Set(BrowserScopes, []string{""}) + + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.ItemCreate(ctx) + return err } -// GetSpec converts echo context to params. -func (w *ServerInterfaceWrapper) GetSpec(ctx echo.Context) error { +// ItemGet converts echo context to params. +func (w *ServerInterfaceWrapper) ItemGet(ctx echo.Context) error { var err error + // ------------- Path parameter "item_slug" ------------- + var itemSlug ItemSlugParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, ctx.Param("item_slug"), &itemSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter item_slug: %s", err)) + } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.GetSpec(ctx) + err = w.Handler.ItemGet(ctx, itemSlug) return err } -// AccountGet converts echo context to params. -func (w *ServerInterfaceWrapper) AccountGet(ctx echo.Context) error { +// ItemUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) ItemUpdate(ctx echo.Context) error { var err error + // ------------- Path parameter "item_slug" ------------- + var itemSlug ItemSlugParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "item_slug", runtime.ParamLocationPath, ctx.Param("item_slug"), &itemSlug) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter item_slug: %s", err)) + } ctx.Set(BrowserScopes, []string{""}) // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AccountGet(ctx) + err = w.Handler.ItemUpdate(ctx, itemSlug) return err } -// AccountUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) AccountUpdate(ctx echo.Context) error { +// PostSearch converts echo context to params. +func (w *ServerInterfaceWrapper) PostSearch(ctx echo.Context) error { var err error - ctx.Set(BrowserScopes, []string{""}) + // Parameter object where we will unmarshal all parameters from the context + var params PostSearchParams + // ------------- Optional query parameter "body" ------------- + + err = runtime.BindQueryParameter("form", true, false, "body", ctx.QueryParams(), ¶ms.Body) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter body: %s", err)) + } + + // ------------- Optional query parameter "author" ------------- + + err = runtime.BindQueryParameter("form", true, false, "author", ctx.QueryParams(), ¶ms.Author) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter author: %s", err)) + } + + // ------------- Optional query parameter "kind" ------------- + + err = runtime.BindQueryParameter("form", true, false, "kind", ctx.QueryParams(), ¶ms.Kind) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter kind: %s", err)) + } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AccountUpdate(ctx) + err = w.Handler.PostSearch(ctx, params) return err } -// AccountAuthProviderList converts echo context to params. -func (w *ServerInterfaceWrapper) AccountAuthProviderList(ctx echo.Context) error { +// PostDelete converts echo context to params. +func (w *ServerInterfaceWrapper) PostDelete(ctx echo.Context) error { var err error + // ------------- Path parameter "post_id" ------------- + var postId PostIDParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) + } + + ctx.Set(BrowserScopes, []string{""}) // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AccountAuthProviderList(ctx) + err = w.Handler.PostDelete(ctx, postId) return err } -// AccountSetAvatar converts echo context to params. -func (w *ServerInterfaceWrapper) AccountSetAvatar(ctx echo.Context) error { +// PostUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) PostUpdate(ctx echo.Context) error { var err error + // ------------- Path parameter "post_id" ------------- + var postId PostIDParam - ctx.Set(BrowserScopes, []string{""}) + err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) + } - // Parameter object where we will unmarshal all parameters from the context - var params AccountSetAvatarParams + ctx.Set(BrowserScopes, []string{""}) - headers := ctx.Request().Header - // ------------- Required header parameter "Content-Length" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { - var ContentLength ContentLength - n := len(valueList) - if n != 1 { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) - } + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.PostUpdate(ctx, postId) + return err +} - err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) - } +// PostReactAdd converts echo context to params. +func (w *ServerInterfaceWrapper) PostReactAdd(ctx echo.Context) error { + var err error + // ------------- Path parameter "post_id" ------------- + var postId PostIDParam - params.ContentLength = ContentLength - } else { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) + err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) } + ctx.Set(BrowserScopes, []string{""}) + // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AccountSetAvatar(ctx, params) + err = w.Handler.PostReactAdd(ctx, postId) return err } -// AccountGetAvatar converts echo context to params. -func (w *ServerInterfaceWrapper) AccountGetAvatar(ctx echo.Context) error { +// ProfileGet converts echo context to params. +func (w *ServerInterfaceWrapper) ProfileGet(ctx echo.Context) error { var err error // ------------- Path parameter "account_handle" ------------- var accountHandle AccountHandleParam @@ -7663,1767 +10468,1642 @@ func (w *ServerInterfaceWrapper) AccountGetAvatar(ctx echo.Context) error { } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AccountGetAvatar(ctx, accountHandle) - return err -} - -// AdminSettingsUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) AdminSettingsUpdate(ctx echo.Context) error { - var err error - - ctx.Set(BrowserScopes, []string{""}) - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AdminSettingsUpdate(ctx) + err = w.Handler.ProfileGet(ctx, accountHandle) return err } -// AssetUpload converts echo context to params. -func (w *ServerInterfaceWrapper) AssetUpload(ctx echo.Context) error { +// ThreadList converts echo context to params. +func (w *ServerInterfaceWrapper) ThreadList(ctx echo.Context) error { var err error - ctx.Set(BrowserScopes, []string{""}) - // Parameter object where we will unmarshal all parameters from the context - var params AssetUploadParams - - headers := ctx.Request().Header - // ------------- Required header parameter "Content-Length" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { - var ContentLength ContentLength - n := len(valueList) - if n != 1 { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) - } - - err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) - } + var params ThreadListParams + // ------------- Optional query parameter "author" ------------- - params.ContentLength = ContentLength - } else { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) + err = runtime.BindQueryParameter("form", true, false, "author", ctx.QueryParams(), ¶ms.Author) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter author: %s", err)) } - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AssetUpload(ctx, params) - return err -} - -// AssetGet converts echo context to params. -func (w *ServerInterfaceWrapper) AssetGet(ctx echo.Context) error { - var err error - // ------------- Path parameter "id" ------------- - var id AssetPath + // ------------- Optional query parameter "tags" ------------- - err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id) + err = runtime.BindQueryParameter("form", true, false, "tags", ctx.QueryParams(), ¶ms.Tags) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tags: %s", err)) } - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AssetGet(ctx, id) - return err -} + // ------------- Optional query parameter "categories" ------------- -// AuthProviderList converts echo context to params. -func (w *ServerInterfaceWrapper) AuthProviderList(ctx echo.Context) error { - var err error + err = runtime.BindQueryParameter("form", true, false, "categories", ctx.QueryParams(), ¶ms.Categories) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter categories: %s", err)) + } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AuthProviderList(ctx) + err = w.Handler.ThreadList(ctx, params) return err } -// AuthProviderLogout converts echo context to params. -func (w *ServerInterfaceWrapper) AuthProviderLogout(ctx echo.Context) error { +// ThreadCreate converts echo context to params. +func (w *ServerInterfaceWrapper) ThreadCreate(ctx echo.Context) error { var err error ctx.Set(BrowserScopes, []string{""}) // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AuthProviderLogout(ctx) + err = w.Handler.ThreadCreate(ctx) return err } -// OAuthProviderCallback converts echo context to params. -func (w *ServerInterfaceWrapper) OAuthProviderCallback(ctx echo.Context) error { +// ThreadDelete converts echo context to params. +func (w *ServerInterfaceWrapper) ThreadDelete(ctx echo.Context) error { var err error - // ------------- Path parameter "oauth_provider" ------------- - var oauthProvider OAuthProvider + // ------------- Path parameter "thread_mark" ------------- + var threadMark ThreadMarkParam - err = runtime.BindStyledParameterWithLocation("simple", false, "oauth_provider", runtime.ParamLocationPath, ctx.Param("oauth_provider"), &oauthProvider) + err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter oauth_provider: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) } + ctx.Set(BrowserScopes, []string{""}) + // Invoke the callback with all the unmarshalled arguments - err = w.Handler.OAuthProviderCallback(ctx, oauthProvider) + err = w.Handler.ThreadDelete(ctx, threadMark) return err } -// AuthPasswordSignin converts echo context to params. -func (w *ServerInterfaceWrapper) AuthPasswordSignin(ctx echo.Context) error { +// ThreadGet converts echo context to params. +func (w *ServerInterfaceWrapper) ThreadGet(ctx echo.Context) error { var err error + // ------------- Path parameter "thread_mark" ------------- + var threadMark ThreadMarkParam + + err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) + } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AuthPasswordSignin(ctx) + err = w.Handler.ThreadGet(ctx, threadMark) return err } -// AuthPasswordSignup converts echo context to params. -func (w *ServerInterfaceWrapper) AuthPasswordSignup(ctx echo.Context) error { +// ThreadUpdate converts echo context to params. +func (w *ServerInterfaceWrapper) ThreadUpdate(ctx echo.Context) error { var err error + // ------------- Path parameter "thread_mark" ------------- + var threadMark ThreadMarkParam - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.AuthPasswordSignup(ctx) - return err -} + err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) + } -// PhoneRequestCode converts echo context to params. -func (w *ServerInterfaceWrapper) PhoneRequestCode(ctx echo.Context) error { - var err error + ctx.Set(BrowserScopes, []string{""}) // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PhoneRequestCode(ctx) + err = w.Handler.ThreadUpdate(ctx, threadMark) return err } -// PhoneSubmitCode converts echo context to params. -func (w *ServerInterfaceWrapper) PhoneSubmitCode(ctx echo.Context) error { +// PostCreate converts echo context to params. +func (w *ServerInterfaceWrapper) PostCreate(ctx echo.Context) error { var err error - // ------------- Path parameter "account_handle" ------------- - var accountHandle AccountHandleParam + // ------------- Path parameter "thread_mark" ------------- + var threadMark ThreadMarkParam - err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) + err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) } + ctx.Set(BrowserScopes, []string{""}) + // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PhoneSubmitCode(ctx, accountHandle) + err = w.Handler.PostCreate(ctx, threadMark) return err } -// WebAuthnMakeAssertion converts echo context to params. -func (w *ServerInterfaceWrapper) WebAuthnMakeAssertion(ctx echo.Context) error { +// GetVersion converts echo context to params. +func (w *ServerInterfaceWrapper) GetVersion(ctx echo.Context) error { var err error - ctx.Set(WebauthnScopes, []string{""}) - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.WebAuthnMakeAssertion(ctx) + err = w.Handler.GetVersion(ctx) return err } -// WebAuthnGetAssertion converts echo context to params. -func (w *ServerInterfaceWrapper) WebAuthnGetAssertion(ctx echo.Context) error { - var err error - // ------------- Path parameter "account_handle" ------------- - var accountHandle AccountHandleParam +// This is a simple interface which specifies echo.Route addition functions which +// are present on both echo.Echo and echo.Group, since we want to allow using +// either of them for path registration +type EchoRouter interface { + CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route +} - err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) +// RegisterHandlers adds each server route to the EchoRouter. +func RegisterHandlers(router EchoRouter, si ServerInterface) { + RegisterHandlersWithBaseURL(router, si, "") +} + +// Registers handlers, and prepends BaseURL to the paths, so that the paths +// can be served under a prefix. +func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { + + wrapper := ServerInterfaceWrapper{ + Handler: si, } - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.WebAuthnGetAssertion(ctx, accountHandle) - return err + router.GET(baseURL+"/openapi.json", wrapper.GetSpec) + router.GET(baseURL+"/v1/accounts", wrapper.AccountGet) + router.PATCH(baseURL+"/v1/accounts", wrapper.AccountUpdate) + router.GET(baseURL+"/v1/accounts/self/auth-methods", wrapper.AccountAuthProviderList) + router.POST(baseURL+"/v1/accounts/self/avatar", wrapper.AccountSetAvatar) + router.GET(baseURL+"/v1/accounts/:account_handle/avatar", wrapper.AccountGetAvatar) + router.PATCH(baseURL+"/v1/admin", wrapper.AdminSettingsUpdate) + router.POST(baseURL+"/v1/assets", wrapper.AssetUpload) + router.GET(baseURL+"/v1/assets/:id", wrapper.AssetGet) + router.GET(baseURL+"/v1/auth", wrapper.AuthProviderList) + router.GET(baseURL+"/v1/auth/logout", wrapper.AuthProviderLogout) + router.POST(baseURL+"/v1/auth/oauth/:oauth_provider/callback", wrapper.OAuthProviderCallback) + router.POST(baseURL+"/v1/auth/password/signin", wrapper.AuthPasswordSignin) + router.POST(baseURL+"/v1/auth/password/signup", wrapper.AuthPasswordSignup) + router.POST(baseURL+"/v1/auth/phone", wrapper.PhoneRequestCode) + router.PUT(baseURL+"/v1/auth/phone/:account_handle", wrapper.PhoneSubmitCode) + router.POST(baseURL+"/v1/auth/webauthn/assert", wrapper.WebAuthnMakeAssertion) + router.GET(baseURL+"/v1/auth/webauthn/assert/:account_handle", wrapper.WebAuthnGetAssertion) + router.POST(baseURL+"/v1/auth/webauthn/make", wrapper.WebAuthnMakeCredential) + router.GET(baseURL+"/v1/auth/webauthn/make/:account_handle", wrapper.WebAuthnRequestCredential) + router.GET(baseURL+"/v1/categories", wrapper.CategoryList) + router.PATCH(baseURL+"/v1/categories", wrapper.CategoryUpdateOrder) + router.POST(baseURL+"/v1/categories", wrapper.CategoryCreate) + router.PATCH(baseURL+"/v1/categories/:category_id", wrapper.CategoryUpdate) + router.GET(baseURL+"/v1/clusters", wrapper.ClusterList) + router.POST(baseURL+"/v1/clusters", wrapper.ClusterCreate) + router.GET(baseURL+"/v1/clusters/:cluster_slug", wrapper.ClusterGet) + router.PATCH(baseURL+"/v1/clusters/:cluster_slug", wrapper.ClusterUpdate) + router.DELETE(baseURL+"/v1/clusters/:cluster_slug/clusters/:cluster_slug_child", wrapper.ClusterRemoveCluster) + router.PUT(baseURL+"/v1/clusters/:cluster_slug/clusters/:cluster_slug_child", wrapper.ClusterAddCluster) + router.DELETE(baseURL+"/v1/clusters/:cluster_slug/items/:item_slug", wrapper.ClusterRemoveItem) + router.PUT(baseURL+"/v1/clusters/:cluster_slug/items/:item_slug", wrapper.ClusterAddItem) + router.GET(baseURL+"/v1/collections", wrapper.CollectionList) + router.POST(baseURL+"/v1/collections", wrapper.CollectionCreate) + router.GET(baseURL+"/v1/collections/:collection_id", wrapper.CollectionGet) + router.PATCH(baseURL+"/v1/collections/:collection_id", wrapper.CollectionUpdate) + router.DELETE(baseURL+"/v1/collections/:collection_id/items/:post_id", wrapper.CollectionRemovePost) + router.PUT(baseURL+"/v1/collections/:collection_id/items/:post_id", wrapper.CollectionAddPost) + router.GET(baseURL+"/v1/info", wrapper.GetInfo) + router.POST(baseURL+"/v1/info/icon", wrapper.IconUpload) + router.GET(baseURL+"/v1/info/icon/:icon_size", wrapper.IconGet) + router.GET(baseURL+"/v1/items", wrapper.ItemList) + router.POST(baseURL+"/v1/items", wrapper.ItemCreate) + router.GET(baseURL+"/v1/items/:item_slug", wrapper.ItemGet) + router.PATCH(baseURL+"/v1/items/:item_slug", wrapper.ItemUpdate) + router.GET(baseURL+"/v1/posts/search", wrapper.PostSearch) + router.DELETE(baseURL+"/v1/posts/:post_id", wrapper.PostDelete) + router.PATCH(baseURL+"/v1/posts/:post_id", wrapper.PostUpdate) + router.PUT(baseURL+"/v1/posts/:post_id/reacts", wrapper.PostReactAdd) + router.GET(baseURL+"/v1/profiles/:account_handle", wrapper.ProfileGet) + router.GET(baseURL+"/v1/threads", wrapper.ThreadList) + router.POST(baseURL+"/v1/threads", wrapper.ThreadCreate) + router.DELETE(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadDelete) + router.GET(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadGet) + router.PATCH(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadUpdate) + router.POST(baseURL+"/v1/threads/:thread_mark/posts", wrapper.PostCreate) + router.GET(baseURL+"/version", wrapper.GetVersion) + } -// WebAuthnMakeCredential converts echo context to params. -func (w *ServerInterfaceWrapper) WebAuthnMakeCredential(ctx echo.Context) error { - var err error +type AccountAuthProviderListOKJSONResponse AccountAuthMethods - ctx.Set(WebauthnScopes, []string{""}) +type AccountGetAvatarImagepngResponse struct { + Body io.Reader - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.WebAuthnMakeCredential(ctx) - return err + ContentLength int64 } -// WebAuthnRequestCredential converts echo context to params. -func (w *ServerInterfaceWrapper) WebAuthnRequestCredential(ctx echo.Context) error { - var err error - // ------------- Path parameter "account_handle" ------------- - var accountHandle AccountHandleParam +type AccountGetOKJSONResponse Account - err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) - } +type AccountUpdateOKJSONResponse Account - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.WebAuthnRequestCredential(ctx, accountHandle) - return err -} +type AdminSettingsUpdateOKJSONResponse AdminSettingsProps -// CategoryList converts echo context to params. -func (w *ServerInterfaceWrapper) CategoryList(ctx echo.Context) error { - var err error +type AssetGetOKAsteriskResponse struct { + Body io.Reader - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CategoryList(ctx) - return err + ContentType string + ContentLength int64 } -// CategoryUpdateOrder converts echo context to params. -func (w *ServerInterfaceWrapper) CategoryUpdateOrder(ctx echo.Context) error { - var err error +type AssetUploadOKJSONResponse Asset - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CategoryUpdateOrder(ctx) - return err +type AuthProviderListOKJSONResponse struct { + Providers AuthProviderList `json:"providers"` } -// CategoryCreate converts echo context to params. -func (w *ServerInterfaceWrapper) CategoryCreate(ctx echo.Context) error { - var err error - - ctx.Set(BrowserScopes, []string{""}) +type AuthSuccessOKResponseHeaders struct { + SetCookie string +} +type AuthSuccessOKJSONResponse struct { + Body AuthSuccess - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CategoryCreate(ctx) - return err + Headers AuthSuccessOKResponseHeaders } -// CategoryUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) CategoryUpdate(ctx echo.Context) error { - var err error - // ------------- Path parameter "category_id" ------------- - var categoryId CategoryIDParam +type BadRequestResponse struct { +} - err = runtime.BindStyledParameterWithLocation("simple", false, "category_id", runtime.ParamLocationPath, ctx.Param("category_id"), &categoryId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter category_id: %s", err)) - } +type CategoryCreateOKJSONResponse Category - ctx.Set(BrowserScopes, []string{""}) +type CategoryListOKJSONResponse CategoryList - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CategoryUpdate(ctx, categoryId) - return err -} +type CategoryUpdateOKJSONResponse Category -// CollectionList converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionList(ctx echo.Context) error { - var err error +type ClusterAddChildOKJSONResponse Cluster - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionList(ctx) - return err -} +type ClusterAddItemOKJSONResponse Cluster -// CollectionCreate converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionCreate(ctx echo.Context) error { - var err error +type ClusterCreateOKJSONResponse Cluster - ctx.Set(BrowserScopes, []string{""}) +type ClusterGetOKJSONResponse ClusterWithItems - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionCreate(ctx) - return err +type ClusterListOKJSONResponse struct { + Clusters ClusterList `json:"clusters"` } -// CollectionGet converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionGet(ctx echo.Context) error { - var err error - // ------------- Path parameter "collection_id" ------------- - var collectionId CollectionIDParam +type ClusterRemoveChildOKJSONResponse Cluster - err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) - } +type ClusterRemoveItemOKJSONResponse Cluster - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionGet(ctx, collectionId) - return err -} +type ClusterUpdateOKJSONResponse Cluster -// CollectionUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionUpdate(ctx echo.Context) error { - var err error - // ------------- Path parameter "collection_id" ------------- - var collectionId CollectionIDParam +type CollectionAddPostOKJSONResponse Collection - err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) - } +type CollectionCreateOKJSONResponse Collection - ctx.Set(BrowserScopes, []string{""}) +type CollectionGetOKJSONResponse CollectionWithItems - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionUpdate(ctx, collectionId) - return err +type CollectionListOKJSONResponse struct { + Collections CollectionList `json:"collections"` } -// CollectionRemovePost converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionRemovePost(ctx echo.Context) error { - var err error - // ------------- Path parameter "collection_id" ------------- - var collectionId CollectionIDParam +type CollectionRemovePostOKJSONResponse Collection - err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) - } +type CollectionUpdateOKJSONResponse Collection - // ------------- Path parameter "post_id" ------------- - var postId PostIDParam +type GetInfoOKJSONResponse Info - err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) - } +type InternalServerErrorJSONResponse APIError - ctx.Set(BrowserScopes, []string{""}) +type ItemCreateOKJSONResponse Item - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionRemovePost(ctx, collectionId, postId) - return err +type ItemGetOKJSONResponse ItemWithParents + +type ItemListOKJSONResponse struct { + // Clusters A list of items where each item includes all the information about its + // parent cluster too. For use with APIs that want to provide a list of + // items that may be part of different clusters. + Clusters ItemList `json:"clusters"` } -// CollectionAddPost converts echo context to params. -func (w *ServerInterfaceWrapper) CollectionAddPost(ctx echo.Context) error { - var err error - // ------------- Path parameter "collection_id" ------------- - var collectionId CollectionIDParam +type ItemUpdateOKJSONResponse Item - err = runtime.BindStyledParameterWithLocation("simple", false, "collection_id", runtime.ParamLocationPath, ctx.Param("collection_id"), &collectionId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter collection_id: %s", err)) - } +type NotFoundResponse struct { +} - // ------------- Path parameter "post_id" ------------- - var postId PostIDParam +type PostCreateOKJSONResponse PostProps - err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) - } +type PostReactAddOKJSONResponse React - ctx.Set(BrowserScopes, []string{""}) +type PostSearchOKJSONResponse PostSearchResults - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CollectionAddPost(ctx, collectionId, postId) - return err -} +type PostUpdateOKJSONResponse PostProps -// GetInfo converts echo context to params. -func (w *ServerInterfaceWrapper) GetInfo(ctx echo.Context) error { - var err error +type ProfileGetOKJSONResponse PublicProfile - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.GetInfo(ctx) - return err +type ThreadCreateOKJSONResponse Thread + +type ThreadGetJSONResponse Thread + +type ThreadListOKJSONResponse struct { + Threads ThreadList `json:"threads"` } -// IconUpload converts echo context to params. -func (w *ServerInterfaceWrapper) IconUpload(ctx echo.Context) error { - var err error +type ThreadUpdateOKJSONResponse Thread - ctx.Set(BrowserScopes, []string{""}) +type UnauthorisedResponse struct { +} - // Parameter object where we will unmarshal all parameters from the context - var params IconUploadParams +type WebAuthnGetAssertionOKResponseHeaders struct { + SetCookie string +} +type WebAuthnGetAssertionOKJSONResponse struct { + Body CredentialRequestOptions - headers := ctx.Request().Header - // ------------- Required header parameter "Content-Length" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("Content-Length")]; found { - var ContentLength ContentLength - n := len(valueList) - if n != 1 { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Content-Length, got %d", n)) - } + Headers WebAuthnGetAssertionOKResponseHeaders +} - err = runtime.BindStyledParameterWithLocation("simple", false, "Content-Length", runtime.ParamLocationHeader, valueList[0], &ContentLength) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Content-Length: %s", err)) - } +type WebAuthnRequestCredentialOKResponseHeaders struct { + SetCookie string +} +type WebAuthnRequestCredentialOKJSONResponse struct { + Body WebAuthnPublicKeyCreationOptions - params.ContentLength = ContentLength - } else { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Content-Length is required, but not found")) - } + Headers WebAuthnRequestCredentialOKResponseHeaders +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.IconUpload(ctx, params) - return err +type GetSpecRequestObject struct { } -// IconGet converts echo context to params. -func (w *ServerInterfaceWrapper) IconGet(ctx echo.Context) error { - var err error - // ------------- Path parameter "icon_size" ------------- - var iconSize IconGetParamsIconSize +type GetSpecResponseObject interface { + VisitGetSpecResponse(w http.ResponseWriter) error +} - err = runtime.BindStyledParameterWithLocation("simple", false, "icon_size", runtime.ParamLocationPath, ctx.Param("icon_size"), &iconSize) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter icon_size: %s", err)) - } +type GetSpec200TextResponse string - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.IconGet(ctx, iconSize) +func (response GetSpec200TextResponse) VisitGetSpecResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(200) + + _, err := w.Write([]byte(response)) return err } -// PostSearch converts echo context to params. -func (w *ServerInterfaceWrapper) PostSearch(ctx echo.Context) error { - var err error +type AccountGetRequestObject struct { +} - // Parameter object where we will unmarshal all parameters from the context - var params PostSearchParams - // ------------- Optional query parameter "body" ------------- +type AccountGetResponseObject interface { + VisitAccountGetResponse(w http.ResponseWriter) error +} - err = runtime.BindQueryParameter("form", true, false, "body", ctx.QueryParams(), ¶ms.Body) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter body: %s", err)) - } +type AccountGet200JSONResponse struct{ AccountGetOKJSONResponse } - // ------------- Optional query parameter "author" ------------- +func (response AccountGet200JSONResponse) VisitAccountGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) - err = runtime.BindQueryParameter("form", true, false, "author", ctx.QueryParams(), ¶ms.Author) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter author: %s", err)) - } + return json.NewEncoder(w).Encode(response) +} - // ------------- Optional query parameter "kind" ------------- +type AccountGet401Response = UnauthorisedResponse - err = runtime.BindQueryParameter("form", true, false, "kind", ctx.QueryParams(), ¶ms.Kind) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter kind: %s", err)) - } +func (response AccountGet401Response) VisitAccountGetResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostSearch(ctx, params) - return err +type AccountGet404Response = NotFoundResponse + +func (response AccountGet404Response) VisitAccountGetResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil } -// PostDelete converts echo context to params. -func (w *ServerInterfaceWrapper) PostDelete(ctx echo.Context) error { - var err error - // ------------- Path parameter "post_id" ------------- - var postId PostIDParam +type AccountGetdefaultJSONResponse struct { + Body APIError + StatusCode int +} - err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) - } +func (response AccountGetdefaultJSONResponse) VisitAccountGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) - ctx.Set(BrowserScopes, []string{""}) + return json.NewEncoder(w).Encode(response.Body) +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostDelete(ctx, postId) - return err +type AccountUpdateRequestObject struct { + Body *AccountUpdateJSONRequestBody } -// PostUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) PostUpdate(ctx echo.Context) error { - var err error - // ------------- Path parameter "post_id" ------------- - var postId PostIDParam +type AccountUpdateResponseObject interface { + VisitAccountUpdateResponse(w http.ResponseWriter) error +} - err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) - } +type AccountUpdate200JSONResponse struct{ AccountUpdateOKJSONResponse } - ctx.Set(BrowserScopes, []string{""}) +func (response AccountUpdate200JSONResponse) VisitAccountUpdateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostUpdate(ctx, postId) - return err + return json.NewEncoder(w).Encode(response) } -// PostReactAdd converts echo context to params. -func (w *ServerInterfaceWrapper) PostReactAdd(ctx echo.Context) error { - var err error - // ------------- Path parameter "post_id" ------------- - var postId PostIDParam +type AccountUpdate401Response = UnauthorisedResponse - err = runtime.BindStyledParameterWithLocation("simple", false, "post_id", runtime.ParamLocationPath, ctx.Param("post_id"), &postId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter post_id: %s", err)) - } +func (response AccountUpdate401Response) VisitAccountUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} - ctx.Set(BrowserScopes, []string{""}) +type AccountUpdate404Response = NotFoundResponse - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostReactAdd(ctx, postId) - return err +func (response AccountUpdate404Response) VisitAccountUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil } -// ProfileGet converts echo context to params. -func (w *ServerInterfaceWrapper) ProfileGet(ctx echo.Context) error { - var err error - // ------------- Path parameter "account_handle" ------------- - var accountHandle AccountHandleParam +type AccountUpdatedefaultJSONResponse struct { + Body APIError + StatusCode int +} - err = runtime.BindStyledParameterWithLocation("simple", false, "account_handle", runtime.ParamLocationPath, ctx.Param("account_handle"), &accountHandle) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter account_handle: %s", err)) - } +func (response AccountUpdatedefaultJSONResponse) VisitAccountUpdateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ProfileGet(ctx, accountHandle) - return err + return json.NewEncoder(w).Encode(response.Body) } -// ThreadList converts echo context to params. -func (w *ServerInterfaceWrapper) ThreadList(ctx echo.Context) error { - var err error +type AccountAuthProviderListRequestObject struct { +} - // Parameter object where we will unmarshal all parameters from the context - var params ThreadListParams - // ------------- Optional query parameter "author" ------------- +type AccountAuthProviderListResponseObject interface { + VisitAccountAuthProviderListResponse(w http.ResponseWriter) error +} - err = runtime.BindQueryParameter("form", true, false, "author", ctx.QueryParams(), ¶ms.Author) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter author: %s", err)) - } +type AccountAuthProviderList200JSONResponse struct { + AccountAuthProviderListOKJSONResponse +} - // ------------- Optional query parameter "tags" ------------- +func (response AccountAuthProviderList200JSONResponse) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) - err = runtime.BindQueryParameter("form", true, false, "tags", ctx.QueryParams(), ¶ms.Tags) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter tags: %s", err)) - } + return json.NewEncoder(w).Encode(response) +} - // ------------- Optional query parameter "categories" ------------- +type AccountAuthProviderList400Response = BadRequestResponse - err = runtime.BindQueryParameter("form", true, false, "categories", ctx.QueryParams(), ¶ms.Categories) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter categories: %s", err)) - } +func (response AccountAuthProviderList400Response) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { + w.WriteHeader(400) + return nil +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ThreadList(ctx, params) - return err +type AccountAuthProviderListdefaultJSONResponse struct { + Body APIError + StatusCode int } -// ThreadCreate converts echo context to params. -func (w *ServerInterfaceWrapper) ThreadCreate(ctx echo.Context) error { - var err error +func (response AccountAuthProviderListdefaultJSONResponse) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) - ctx.Set(BrowserScopes, []string{""}) + return json.NewEncoder(w).Encode(response.Body) +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ThreadCreate(ctx) - return err +type AccountSetAvatarRequestObject struct { + Params AccountSetAvatarParams + Body io.Reader } -// ThreadDelete converts echo context to params. -func (w *ServerInterfaceWrapper) ThreadDelete(ctx echo.Context) error { - var err error - // ------------- Path parameter "thread_mark" ------------- - var threadMark ThreadMarkParam +type AccountSetAvatarResponseObject interface { + VisitAccountSetAvatarResponse(w http.ResponseWriter) error +} - err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) - } +type AccountSetAvatar200Response struct { +} - ctx.Set(BrowserScopes, []string{""}) +func (response AccountSetAvatar200Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { + w.WriteHeader(200) + return nil +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ThreadDelete(ctx, threadMark) - return err +type AccountSetAvatar401Response = UnauthorisedResponse + +func (response AccountSetAvatar401Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -// ThreadGet converts echo context to params. -func (w *ServerInterfaceWrapper) ThreadGet(ctx echo.Context) error { - var err error - // ------------- Path parameter "thread_mark" ------------- - var threadMark ThreadMarkParam +type AccountSetAvatar404Response = NotFoundResponse - err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) - } +func (response AccountSetAvatar404Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ThreadGet(ctx, threadMark) - return err +type AccountSetAvatardefaultJSONResponse struct { + Body APIError + StatusCode int } -// ThreadUpdate converts echo context to params. -func (w *ServerInterfaceWrapper) ThreadUpdate(ctx echo.Context) error { - var err error - // ------------- Path parameter "thread_mark" ------------- - var threadMark ThreadMarkParam +func (response AccountSetAvatardefaultJSONResponse) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) - err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) - } + return json.NewEncoder(w).Encode(response.Body) +} - ctx.Set(BrowserScopes, []string{""}) +type AccountGetAvatarRequestObject struct { + AccountHandle AccountHandleParam `json:"account_handle"` +} - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.ThreadUpdate(ctx, threadMark) - return err +type AccountGetAvatarResponseObject interface { + VisitAccountGetAvatarResponse(w http.ResponseWriter) error } -// PostCreate converts echo context to params. -func (w *ServerInterfaceWrapper) PostCreate(ctx echo.Context) error { - var err error - // ------------- Path parameter "thread_mark" ------------- - var threadMark ThreadMarkParam +type AccountGetAvatar200ImagepngResponse struct { + AccountGetAvatarImagepngResponse +} - err = runtime.BindStyledParameterWithLocation("simple", false, "thread_mark", runtime.ParamLocationPath, ctx.Param("thread_mark"), &threadMark) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter thread_mark: %s", err)) +func (response AccountGetAvatar200ImagepngResponse) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "image/png") + if response.ContentLength != 0 { + w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) } + w.WriteHeader(200) - ctx.Set(BrowserScopes, []string{""}) - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostCreate(ctx, threadMark) + if closer, ok := response.Body.(io.ReadCloser); ok { + defer closer.Close() + } + _, err := io.Copy(w, response.Body) return err } -// GetVersion converts echo context to params. -func (w *ServerInterfaceWrapper) GetVersion(ctx echo.Context) error { - var err error +type AccountGetAvatar401Response = UnauthorisedResponse - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.GetVersion(ctx) - return err +func (response AccountGetAvatar401Response) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -// This is a simple interface which specifies echo.Route addition functions which -// are present on both echo.Echo and echo.Group, since we want to allow using -// either of them for path registration -type EchoRouter interface { - CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route -} +type AccountGetAvatar404Response = NotFoundResponse -// RegisterHandlers adds each server route to the EchoRouter. -func RegisterHandlers(router EchoRouter, si ServerInterface) { - RegisterHandlersWithBaseURL(router, si, "") +func (response AccountGetAvatar404Response) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil } -// Registers handlers, and prepends BaseURL to the paths, so that the paths -// can be served under a prefix. -func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { - - wrapper := ServerInterfaceWrapper{ - Handler: si, - } +type AccountGetAvatardefaultJSONResponse struct { + Body APIError + StatusCode int +} - router.GET(baseURL+"/openapi.json", wrapper.GetSpec) - router.GET(baseURL+"/v1/accounts", wrapper.AccountGet) - router.PATCH(baseURL+"/v1/accounts", wrapper.AccountUpdate) - router.GET(baseURL+"/v1/accounts/self/auth-methods", wrapper.AccountAuthProviderList) - router.POST(baseURL+"/v1/accounts/self/avatar", wrapper.AccountSetAvatar) - router.GET(baseURL+"/v1/accounts/:account_handle/avatar", wrapper.AccountGetAvatar) - router.PATCH(baseURL+"/v1/admin", wrapper.AdminSettingsUpdate) - router.POST(baseURL+"/v1/assets", wrapper.AssetUpload) - router.GET(baseURL+"/v1/assets/:id", wrapper.AssetGet) - router.GET(baseURL+"/v1/auth", wrapper.AuthProviderList) - router.GET(baseURL+"/v1/auth/logout", wrapper.AuthProviderLogout) - router.POST(baseURL+"/v1/auth/oauth/:oauth_provider/callback", wrapper.OAuthProviderCallback) - router.POST(baseURL+"/v1/auth/password/signin", wrapper.AuthPasswordSignin) - router.POST(baseURL+"/v1/auth/password/signup", wrapper.AuthPasswordSignup) - router.POST(baseURL+"/v1/auth/phone", wrapper.PhoneRequestCode) - router.PUT(baseURL+"/v1/auth/phone/:account_handle", wrapper.PhoneSubmitCode) - router.POST(baseURL+"/v1/auth/webauthn/assert", wrapper.WebAuthnMakeAssertion) - router.GET(baseURL+"/v1/auth/webauthn/assert/:account_handle", wrapper.WebAuthnGetAssertion) - router.POST(baseURL+"/v1/auth/webauthn/make", wrapper.WebAuthnMakeCredential) - router.GET(baseURL+"/v1/auth/webauthn/make/:account_handle", wrapper.WebAuthnRequestCredential) - router.GET(baseURL+"/v1/categories", wrapper.CategoryList) - router.PATCH(baseURL+"/v1/categories", wrapper.CategoryUpdateOrder) - router.POST(baseURL+"/v1/categories", wrapper.CategoryCreate) - router.PATCH(baseURL+"/v1/categories/:category_id", wrapper.CategoryUpdate) - router.GET(baseURL+"/v1/collections", wrapper.CollectionList) - router.POST(baseURL+"/v1/collections", wrapper.CollectionCreate) - router.GET(baseURL+"/v1/collections/:collection_id", wrapper.CollectionGet) - router.PATCH(baseURL+"/v1/collections/:collection_id", wrapper.CollectionUpdate) - router.DELETE(baseURL+"/v1/collections/:collection_id/items/:post_id", wrapper.CollectionRemovePost) - router.PUT(baseURL+"/v1/collections/:collection_id/items/:post_id", wrapper.CollectionAddPost) - router.GET(baseURL+"/v1/info", wrapper.GetInfo) - router.POST(baseURL+"/v1/info/icon", wrapper.IconUpload) - router.GET(baseURL+"/v1/info/icon/:icon_size", wrapper.IconGet) - router.GET(baseURL+"/v1/posts/search", wrapper.PostSearch) - router.DELETE(baseURL+"/v1/posts/:post_id", wrapper.PostDelete) - router.PATCH(baseURL+"/v1/posts/:post_id", wrapper.PostUpdate) - router.PUT(baseURL+"/v1/posts/:post_id/reacts", wrapper.PostReactAdd) - router.GET(baseURL+"/v1/profiles/:account_handle", wrapper.ProfileGet) - router.GET(baseURL+"/v1/threads", wrapper.ThreadList) - router.POST(baseURL+"/v1/threads", wrapper.ThreadCreate) - router.DELETE(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadDelete) - router.GET(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadGet) - router.PATCH(baseURL+"/v1/threads/:thread_mark", wrapper.ThreadUpdate) - router.POST(baseURL+"/v1/threads/:thread_mark/posts", wrapper.PostCreate) - router.GET(baseURL+"/version", wrapper.GetVersion) +func (response AccountGetAvatardefaultJSONResponse) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) + return json.NewEncoder(w).Encode(response.Body) } -type AccountAuthProviderListOKJSONResponse AccountAuthMethods - -type AccountGetAvatarImagepngResponse struct { - Body io.Reader +type AdminSettingsUpdateRequestObject struct { + Body *AdminSettingsUpdateJSONRequestBody +} - ContentLength int64 +type AdminSettingsUpdateResponseObject interface { + VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error } -type AccountGetOKJSONResponse Account +type AdminSettingsUpdate200JSONResponse struct { + AdminSettingsUpdateOKJSONResponse +} -type AccountUpdateOKJSONResponse Account +func (response AdminSettingsUpdate200JSONResponse) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) -type AdminSettingsUpdateOKJSONResponse AdminSettingsProps + return json.NewEncoder(w).Encode(response) +} -type AssetGetOKAsteriskResponse struct { - Body io.Reader +type AdminSettingsUpdate400Response = BadRequestResponse - ContentType string - ContentLength int64 +func (response AdminSettingsUpdate400Response) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(400) + return nil } -type AssetUploadOKJSONResponse Asset +type AdminSettingsUpdate401Response = UnauthorisedResponse -type AuthProviderListOKJSONResponse struct { - Providers AuthProviderList `json:"providers"` +func (response AdminSettingsUpdate401Response) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -type AuthSuccessOKResponseHeaders struct { - SetCookie string +type AdminSettingsUpdatedefaultJSONResponse struct { + Body APIError + StatusCode int } -type AuthSuccessOKJSONResponse struct { - Body AuthSuccess - Headers AuthSuccessOKResponseHeaders -} +func (response AdminSettingsUpdatedefaultJSONResponse) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) -type BadRequestResponse struct { + return json.NewEncoder(w).Encode(response.Body) } -type CategoryCreateOKJSONResponse Category +type AssetUploadRequestObject struct { + Params AssetUploadParams + Body io.Reader +} -type CategoryListOKJSONResponse CategoryList +type AssetUploadResponseObject interface { + VisitAssetUploadResponse(w http.ResponseWriter) error +} -type CategoryUpdateOKJSONResponse Category +type AssetUpload200JSONResponse struct{ AssetUploadOKJSONResponse } -type CollectionAddPostOKJSONResponse Collection +func (response AssetUpload200JSONResponse) VisitAssetUploadResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) -type CollectionCreateOKJSONResponse Collection + return json.NewEncoder(w).Encode(response) +} -type CollectionGetOKJSONResponse CollectionWithItems +type AssetUpload401Response = UnauthorisedResponse -type CollectionListOKJSONResponse struct { - Collections CollectionList `json:"collections"` +func (response AssetUpload401Response) VisitAssetUploadResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -type CollectionRemovePostOKJSONResponse Collection +type AssetUploaddefaultJSONResponse struct { + Body APIError + StatusCode int +} -type CollectionUpdateOKJSONResponse Collection +func (response AssetUploaddefaultJSONResponse) VisitAssetUploadResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) -type GetInfoOKJSONResponse Info + return json.NewEncoder(w).Encode(response.Body) +} -type InternalServerErrorJSONResponse APIError +type AssetGetRequestObject struct { + Id AssetPath `json:"id"` +} -type NotFoundResponse struct { +type AssetGetResponseObject interface { + VisitAssetGetResponse(w http.ResponseWriter) error } -type PostCreateOKJSONResponse PostProps +type AssetGet200AsteriskResponse struct{ AssetGetOKAsteriskResponse } -type PostReactAddOKJSONResponse React +func (response AssetGet200AsteriskResponse) VisitAssetGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", response.ContentType) + if response.ContentLength != 0 { + w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) + } + w.WriteHeader(200) -type PostSearchOKJSONResponse PostSearchResults + if closer, ok := response.Body.(io.ReadCloser); ok { + defer closer.Close() + } + _, err := io.Copy(w, response.Body) + return err +} -type PostUpdateOKJSONResponse PostProps +type AssetGet401Response = UnauthorisedResponse -type ProfileGetOKJSONResponse PublicProfile +func (response AssetGet401Response) VisitAssetGetResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} -type ThreadCreateOKJSONResponse Thread +type AssetGet404Response = NotFoundResponse -type ThreadGetJSONResponse Thread +func (response AssetGet404Response) VisitAssetGetResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} -type ThreadListOKJSONResponse struct { - Threads ThreadList `json:"threads"` +type AssetGetdefaultJSONResponse struct { + Body APIError + StatusCode int } -type ThreadUpdateOKJSONResponse Thread +func (response AssetGetdefaultJSONResponse) VisitAssetGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) -type UnauthorisedResponse struct { + return json.NewEncoder(w).Encode(response.Body) } -type WebAuthnGetAssertionOKResponseHeaders struct { - SetCookie string +type AuthProviderListRequestObject struct { } -type WebAuthnGetAssertionOKJSONResponse struct { - Body CredentialRequestOptions - Headers WebAuthnGetAssertionOKResponseHeaders +type AuthProviderListResponseObject interface { + VisitAuthProviderListResponse(w http.ResponseWriter) error } -type WebAuthnRequestCredentialOKResponseHeaders struct { - SetCookie string -} -type WebAuthnRequestCredentialOKJSONResponse struct { - Body WebAuthnPublicKeyCreationOptions +type AuthProviderList200JSONResponse struct{ AuthProviderListOKJSONResponse } + +func (response AuthProviderList200JSONResponse) VisitAuthProviderListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) - Headers WebAuthnRequestCredentialOKResponseHeaders + return json.NewEncoder(w).Encode(response) } -type GetSpecRequestObject struct { -} +type AuthProviderList400Response = BadRequestResponse -type GetSpecResponseObject interface { - VisitGetSpecResponse(w http.ResponseWriter) error +func (response AuthProviderList400Response) VisitAuthProviderListResponse(w http.ResponseWriter) error { + w.WriteHeader(400) + return nil } -type GetSpec200TextResponse string +type AuthProviderListdefaultJSONResponse struct { + Body APIError + StatusCode int +} -func (response GetSpec200TextResponse) VisitGetSpecResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", "text/plain") - w.WriteHeader(200) +func (response AuthProviderListdefaultJSONResponse) VisitAuthProviderListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) - _, err := w.Write([]byte(response)) - return err + return json.NewEncoder(w).Encode(response.Body) } -type AccountGetRequestObject struct { +type AuthProviderLogoutRequestObject struct { } -type AccountGetResponseObject interface { - VisitAccountGetResponse(w http.ResponseWriter) error +type AuthProviderLogoutResponseObject interface { + VisitAuthProviderLogoutResponse(w http.ResponseWriter) error } -type AccountGet200JSONResponse struct{ AccountGetOKJSONResponse } - -func (response AccountGet200JSONResponse) VisitAccountGetResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(200) - - return json.NewEncoder(w).Encode(response) +type AuthProviderLogout200ResponseHeaders struct { + SetCookie string } -type AccountGet401Response = UnauthorisedResponse +type AuthProviderLogout200Response struct { + Headers AuthProviderLogout200ResponseHeaders +} -func (response AccountGet401Response) VisitAccountGetResponse(w http.ResponseWriter) error { - w.WriteHeader(401) +func (response AuthProviderLogout200Response) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) + w.WriteHeader(200) return nil } -type AccountGet404Response = NotFoundResponse +type AuthProviderLogout400Response = BadRequestResponse -func (response AccountGet404Response) VisitAccountGetResponse(w http.ResponseWriter) error { - w.WriteHeader(404) +func (response AuthProviderLogout400Response) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { + w.WriteHeader(400) return nil } -type AccountGetdefaultJSONResponse struct { +type AuthProviderLogoutdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AccountGetdefaultJSONResponse) VisitAccountGetResponse(w http.ResponseWriter) error { +func (response AuthProviderLogoutdefaultJSONResponse) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AccountUpdateRequestObject struct { - Body *AccountUpdateJSONRequestBody +type OAuthProviderCallbackRequestObject struct { + OauthProvider OAuthProvider `json:"oauth_provider"` + Body *OAuthProviderCallbackJSONRequestBody } -type AccountUpdateResponseObject interface { - VisitAccountUpdateResponse(w http.ResponseWriter) error +type OAuthProviderCallbackResponseObject interface { + VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error } -type AccountUpdate200JSONResponse struct{ AccountUpdateOKJSONResponse } +type OAuthProviderCallback200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AccountUpdate200JSONResponse) VisitAccountUpdateResponse(w http.ResponseWriter) error { +func (response OAuthProviderCallback200JSONResponse) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response) + return json.NewEncoder(w).Encode(response.Body) } -type AccountUpdate401Response = UnauthorisedResponse +type OAuthProviderCallback401Response = UnauthorisedResponse -func (response AccountUpdate401Response) VisitAccountUpdateResponse(w http.ResponseWriter) error { +func (response OAuthProviderCallback401Response) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { w.WriteHeader(401) return nil } -type AccountUpdate404Response = NotFoundResponse +type OAuthProviderCallback404Response = NotFoundResponse -func (response AccountUpdate404Response) VisitAccountUpdateResponse(w http.ResponseWriter) error { +func (response OAuthProviderCallback404Response) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type AccountUpdatedefaultJSONResponse struct { +type OAuthProviderCallbackdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AccountUpdatedefaultJSONResponse) VisitAccountUpdateResponse(w http.ResponseWriter) error { +func (response OAuthProviderCallbackdefaultJSONResponse) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AccountAuthProviderListRequestObject struct { +type AuthPasswordSigninRequestObject struct { + Body *AuthPasswordSigninJSONRequestBody } -type AccountAuthProviderListResponseObject interface { - VisitAccountAuthProviderListResponse(w http.ResponseWriter) error +type AuthPasswordSigninResponseObject interface { + VisitAuthPasswordSigninResponse(w http.ResponseWriter) error } -type AccountAuthProviderList200JSONResponse struct { - AccountAuthProviderListOKJSONResponse -} +type AuthPasswordSignin200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AccountAuthProviderList200JSONResponse) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { +func (response AuthPasswordSignin200JSONResponse) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response) + return json.NewEncoder(w).Encode(response.Body) } -type AccountAuthProviderList400Response = BadRequestResponse +type AuthPasswordSignin401Response = UnauthorisedResponse -func (response AccountAuthProviderList400Response) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response AuthPasswordSignin401Response) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { + w.WriteHeader(401) return nil } -type AccountAuthProviderListdefaultJSONResponse struct { +type AuthPasswordSignin404Response = NotFoundResponse + +func (response AuthPasswordSignin404Response) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type AuthPasswordSignindefaultJSONResponse struct { Body APIError StatusCode int } -func (response AccountAuthProviderListdefaultJSONResponse) VisitAccountAuthProviderListResponse(w http.ResponseWriter) error { +func (response AuthPasswordSignindefaultJSONResponse) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AccountSetAvatarRequestObject struct { - Params AccountSetAvatarParams - Body io.Reader +type AuthPasswordSignupRequestObject struct { + Body *AuthPasswordSignupJSONRequestBody } -type AccountSetAvatarResponseObject interface { - VisitAccountSetAvatarResponse(w http.ResponseWriter) error +type AuthPasswordSignupResponseObject interface { + VisitAuthPasswordSignupResponse(w http.ResponseWriter) error } -type AccountSetAvatar200Response struct { -} +type AuthPasswordSignup200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AccountSetAvatar200Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { +func (response AuthPasswordSignup200JSONResponse) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return nil -} - -type AccountSetAvatar401Response = UnauthorisedResponse -func (response AccountSetAvatar401Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { - w.WriteHeader(401) - return nil + return json.NewEncoder(w).Encode(response.Body) } -type AccountSetAvatar404Response = NotFoundResponse +type AuthPasswordSignup400Response = BadRequestResponse -func (response AccountSetAvatar404Response) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { - w.WriteHeader(404) +func (response AuthPasswordSignup400Response) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { + w.WriteHeader(400) return nil } -type AccountSetAvatardefaultJSONResponse struct { +type AuthPasswordSignupdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AccountSetAvatardefaultJSONResponse) VisitAccountSetAvatarResponse(w http.ResponseWriter) error { +func (response AuthPasswordSignupdefaultJSONResponse) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AccountGetAvatarRequestObject struct { - AccountHandle AccountHandleParam `json:"account_handle"` +type PhoneRequestCodeRequestObject struct { + Body *PhoneRequestCodeJSONRequestBody } -type AccountGetAvatarResponseObject interface { - VisitAccountGetAvatarResponse(w http.ResponseWriter) error +type PhoneRequestCodeResponseObject interface { + VisitPhoneRequestCodeResponse(w http.ResponseWriter) error } -type AccountGetAvatar200ImagepngResponse struct { - AccountGetAvatarImagepngResponse -} +type PhoneRequestCode200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AccountGetAvatar200ImagepngResponse) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", "image/png") - if response.ContentLength != 0 { - w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) - } +func (response PhoneRequestCode200JSONResponse) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - if closer, ok := response.Body.(io.ReadCloser); ok { - defer closer.Close() - } - _, err := io.Copy(w, response.Body) - return err -} - -type AccountGetAvatar401Response = UnauthorisedResponse - -func (response AccountGetAvatar401Response) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { - w.WriteHeader(401) - return nil + return json.NewEncoder(w).Encode(response.Body) } -type AccountGetAvatar404Response = NotFoundResponse +type PhoneRequestCode400Response = BadRequestResponse -func (response AccountGetAvatar404Response) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { - w.WriteHeader(404) +func (response PhoneRequestCode400Response) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { + w.WriteHeader(400) return nil } -type AccountGetAvatardefaultJSONResponse struct { +type PhoneRequestCodedefaultJSONResponse struct { Body APIError StatusCode int } -func (response AccountGetAvatardefaultJSONResponse) VisitAccountGetAvatarResponse(w http.ResponseWriter) error { +func (response PhoneRequestCodedefaultJSONResponse) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AdminSettingsUpdateRequestObject struct { - Body *AdminSettingsUpdateJSONRequestBody +type PhoneSubmitCodeRequestObject struct { + AccountHandle AccountHandleParam `json:"account_handle"` + Body *PhoneSubmitCodeJSONRequestBody } -type AdminSettingsUpdateResponseObject interface { - VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error +type PhoneSubmitCodeResponseObject interface { + VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error } -type AdminSettingsUpdate200JSONResponse struct { - AdminSettingsUpdateOKJSONResponse -} +type PhoneSubmitCode200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AdminSettingsUpdate200JSONResponse) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { +func (response PhoneSubmitCode200JSONResponse) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response) + return json.NewEncoder(w).Encode(response.Body) } -type AdminSettingsUpdate400Response = BadRequestResponse +type PhoneSubmitCode400Response = BadRequestResponse -func (response AdminSettingsUpdate400Response) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { +func (response PhoneSubmitCode400Response) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { w.WriteHeader(400) return nil } -type AdminSettingsUpdate401Response = UnauthorisedResponse - -func (response AdminSettingsUpdate401Response) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { - w.WriteHeader(401) - return nil -} - -type AdminSettingsUpdatedefaultJSONResponse struct { +type PhoneSubmitCodedefaultJSONResponse struct { Body APIError StatusCode int } -func (response AdminSettingsUpdatedefaultJSONResponse) VisitAdminSettingsUpdateResponse(w http.ResponseWriter) error { +func (response PhoneSubmitCodedefaultJSONResponse) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AssetUploadRequestObject struct { - Params AssetUploadParams - Body io.Reader +type WebAuthnMakeAssertionRequestObject struct { + Body *WebAuthnMakeAssertionJSONRequestBody } -type AssetUploadResponseObject interface { - VisitAssetUploadResponse(w http.ResponseWriter) error +type WebAuthnMakeAssertionResponseObject interface { + VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error } -type AssetUpload200JSONResponse struct{ AssetUploadOKJSONResponse } +type WebAuthnMakeAssertion200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AssetUpload200JSONResponse) VisitAssetUploadResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeAssertion200JSONResponse) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response) + return json.NewEncoder(w).Encode(response.Body) } -type AssetUpload401Response = UnauthorisedResponse +type WebAuthnMakeAssertion401Response = UnauthorisedResponse -func (response AssetUpload401Response) VisitAssetUploadResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeAssertion401Response) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { w.WriteHeader(401) return nil } -type AssetUploaddefaultJSONResponse struct { +type WebAuthnMakeAssertion404Response = NotFoundResponse + +func (response WebAuthnMakeAssertion404Response) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type WebAuthnMakeAssertiondefaultJSONResponse struct { Body APIError StatusCode int } -func (response AssetUploaddefaultJSONResponse) VisitAssetUploadResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeAssertiondefaultJSONResponse) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AssetGetRequestObject struct { - Id AssetPath `json:"id"` +type WebAuthnGetAssertionRequestObject struct { + AccountHandle AccountHandleParam `json:"account_handle"` } -type AssetGetResponseObject interface { - VisitAssetGetResponse(w http.ResponseWriter) error +type WebAuthnGetAssertionResponseObject interface { + VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error } -type AssetGet200AsteriskResponse struct{ AssetGetOKAsteriskResponse } +type WebAuthnGetAssertion200JSONResponse struct { + WebAuthnGetAssertionOKJSONResponse +} -func (response AssetGet200AsteriskResponse) VisitAssetGetResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", response.ContentType) - if response.ContentLength != 0 { - w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) - } +func (response WebAuthnGetAssertion200JSONResponse) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - if closer, ok := response.Body.(io.ReadCloser); ok { - defer closer.Close() - } - _, err := io.Copy(w, response.Body) - return err + return json.NewEncoder(w).Encode(response.Body) } -type AssetGet401Response = UnauthorisedResponse +type WebAuthnGetAssertion401Response = UnauthorisedResponse -func (response AssetGet401Response) VisitAssetGetResponse(w http.ResponseWriter) error { +func (response WebAuthnGetAssertion401Response) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { w.WriteHeader(401) return nil } -type AssetGet404Response = NotFoundResponse +type WebAuthnGetAssertion404Response = NotFoundResponse -func (response AssetGet404Response) VisitAssetGetResponse(w http.ResponseWriter) error { +func (response WebAuthnGetAssertion404Response) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type AssetGetdefaultJSONResponse struct { +type WebAuthnGetAssertiondefaultJSONResponse struct { Body APIError StatusCode int } -func (response AssetGetdefaultJSONResponse) VisitAssetGetResponse(w http.ResponseWriter) error { +func (response WebAuthnGetAssertiondefaultJSONResponse) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AuthProviderListRequestObject struct { +type WebAuthnMakeCredentialRequestObject struct { + Body *WebAuthnMakeCredentialJSONRequestBody } -type AuthProviderListResponseObject interface { - VisitAuthProviderListResponse(w http.ResponseWriter) error +type WebAuthnMakeCredentialResponseObject interface { + VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error } -type AuthProviderList200JSONResponse struct{ AuthProviderListOKJSONResponse } +type WebAuthnMakeCredential200JSONResponse struct{ AuthSuccessOKJSONResponse } -func (response AuthProviderList200JSONResponse) VisitAuthProviderListResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeCredential200JSONResponse) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { + w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response) + return json.NewEncoder(w).Encode(response.Body) } -type AuthProviderList400Response = BadRequestResponse +type WebAuthnMakeCredential400Response = BadRequestResponse -func (response AuthProviderList400Response) VisitAuthProviderListResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeCredential400Response) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { w.WriteHeader(400) return nil } -type AuthProviderListdefaultJSONResponse struct { +type WebAuthnMakeCredentialdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AuthProviderListdefaultJSONResponse) VisitAuthProviderListResponse(w http.ResponseWriter) error { +func (response WebAuthnMakeCredentialdefaultJSONResponse) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AuthProviderLogoutRequestObject struct { -} - -type AuthProviderLogoutResponseObject interface { - VisitAuthProviderLogoutResponse(w http.ResponseWriter) error +type WebAuthnRequestCredentialRequestObject struct { + AccountHandle AccountHandleParam `json:"account_handle"` } -type AuthProviderLogout200ResponseHeaders struct { - SetCookie string +type WebAuthnRequestCredentialResponseObject interface { + VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error } -type AuthProviderLogout200Response struct { - Headers AuthProviderLogout200ResponseHeaders +type WebAuthnRequestCredential200JSONResponse struct { + WebAuthnRequestCredentialOKJSONResponse } -func (response AuthProviderLogout200Response) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { +func (response WebAuthnRequestCredential200JSONResponse) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return nil + + return json.NewEncoder(w).Encode(response.Body) } -type AuthProviderLogout400Response = BadRequestResponse +type WebAuthnRequestCredential400Response = BadRequestResponse -func (response AuthProviderLogout400Response) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { +func (response WebAuthnRequestCredential400Response) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { w.WriteHeader(400) return nil } -type AuthProviderLogoutdefaultJSONResponse struct { +type WebAuthnRequestCredentialdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AuthProviderLogoutdefaultJSONResponse) VisitAuthProviderLogoutResponse(w http.ResponseWriter) error { +func (response WebAuthnRequestCredentialdefaultJSONResponse) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type OAuthProviderCallbackRequestObject struct { - OauthProvider OAuthProvider `json:"oauth_provider"` - Body *OAuthProviderCallbackJSONRequestBody +type CategoryListRequestObject struct { } -type OAuthProviderCallbackResponseObject interface { - VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error +type CategoryListResponseObject interface { + VisitCategoryListResponse(w http.ResponseWriter) error } -type OAuthProviderCallback200JSONResponse struct{ AuthSuccessOKJSONResponse } +type CategoryList200JSONResponse struct{ CategoryListOKJSONResponse } -func (response OAuthProviderCallback200JSONResponse) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response CategoryList200JSONResponse) VisitCategoryListResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) -} - -type OAuthProviderCallback401Response = UnauthorisedResponse - -func (response OAuthProviderCallback401Response) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { - w.WriteHeader(401) - return nil -} - -type OAuthProviderCallback404Response = NotFoundResponse - -func (response OAuthProviderCallback404Response) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { - w.WriteHeader(404) - return nil + return json.NewEncoder(w).Encode(response) } -type OAuthProviderCallbackdefaultJSONResponse struct { +type CategoryListdefaultJSONResponse struct { Body APIError StatusCode int } -func (response OAuthProviderCallbackdefaultJSONResponse) VisitOAuthProviderCallbackResponse(w http.ResponseWriter) error { +func (response CategoryListdefaultJSONResponse) VisitCategoryListResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AuthPasswordSigninRequestObject struct { - Body *AuthPasswordSigninJSONRequestBody +type CategoryUpdateOrderRequestObject struct { + Body *CategoryUpdateOrderJSONRequestBody } -type AuthPasswordSigninResponseObject interface { - VisitAuthPasswordSigninResponse(w http.ResponseWriter) error +type CategoryUpdateOrderResponseObject interface { + VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error } -type AuthPasswordSignin200JSONResponse struct{ AuthSuccessOKJSONResponse } +type CategoryUpdateOrder200JSONResponse struct{ CategoryListOKJSONResponse } -func (response AuthPasswordSignin200JSONResponse) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response CategoryUpdateOrder200JSONResponse) VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) -} - -type AuthPasswordSignin401Response = UnauthorisedResponse - -func (response AuthPasswordSignin401Response) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { - w.WriteHeader(401) - return nil -} - -type AuthPasswordSignin404Response = NotFoundResponse - -func (response AuthPasswordSignin404Response) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { - w.WriteHeader(404) - return nil + return json.NewEncoder(w).Encode(response) } -type AuthPasswordSignindefaultJSONResponse struct { +type CategoryUpdateOrderdefaultJSONResponse struct { Body APIError StatusCode int } -func (response AuthPasswordSignindefaultJSONResponse) VisitAuthPasswordSigninResponse(w http.ResponseWriter) error { +func (response CategoryUpdateOrderdefaultJSONResponse) VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type AuthPasswordSignupRequestObject struct { - Body *AuthPasswordSignupJSONRequestBody +type CategoryCreateRequestObject struct { + Body *CategoryCreateJSONRequestBody } -type AuthPasswordSignupResponseObject interface { - VisitAuthPasswordSignupResponse(w http.ResponseWriter) error +type CategoryCreateResponseObject interface { + VisitCategoryCreateResponse(w http.ResponseWriter) error } -type AuthPasswordSignup200JSONResponse struct{ AuthSuccessOKJSONResponse } +type CategoryCreate200JSONResponse struct{ CategoryCreateOKJSONResponse } -func (response AuthPasswordSignup200JSONResponse) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response CategoryCreate200JSONResponse) VisitCategoryCreateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type AuthPasswordSignup400Response = BadRequestResponse +type CategoryCreate400Response = BadRequestResponse -func (response AuthPasswordSignup400Response) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { +func (response CategoryCreate400Response) VisitCategoryCreateResponse(w http.ResponseWriter) error { w.WriteHeader(400) return nil } -type AuthPasswordSignupdefaultJSONResponse struct { +type CategoryCreate401Response = UnauthorisedResponse + +func (response CategoryCreate401Response) VisitCategoryCreateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type CategoryCreatedefaultJSONResponse struct { Body APIError StatusCode int } -func (response AuthPasswordSignupdefaultJSONResponse) VisitAuthPasswordSignupResponse(w http.ResponseWriter) error { +func (response CategoryCreatedefaultJSONResponse) VisitCategoryCreateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type PhoneRequestCodeRequestObject struct { - Body *PhoneRequestCodeJSONRequestBody +type CategoryUpdateRequestObject struct { + CategoryId CategoryIDParam `json:"category_id"` + Body *CategoryUpdateJSONRequestBody } -type PhoneRequestCodeResponseObject interface { - VisitPhoneRequestCodeResponse(w http.ResponseWriter) error +type CategoryUpdateResponseObject interface { + VisitCategoryUpdateResponse(w http.ResponseWriter) error } -type PhoneRequestCode200JSONResponse struct{ AuthSuccessOKJSONResponse } +type CategoryUpdate200JSONResponse struct{ CategoryUpdateOKJSONResponse } -func (response PhoneRequestCode200JSONResponse) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response CategoryUpdate200JSONResponse) VisitCategoryUpdateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type PhoneRequestCode400Response = BadRequestResponse +type CategoryUpdate400Response = BadRequestResponse -func (response PhoneRequestCode400Response) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { +func (response CategoryUpdate400Response) VisitCategoryUpdateResponse(w http.ResponseWriter) error { w.WriteHeader(400) return nil } -type PhoneRequestCodedefaultJSONResponse struct { +type CategoryUpdate401Response = UnauthorisedResponse + +func (response CategoryUpdate401Response) VisitCategoryUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type CategoryUpdatedefaultJSONResponse struct { Body APIError StatusCode int } -func (response PhoneRequestCodedefaultJSONResponse) VisitPhoneRequestCodeResponse(w http.ResponseWriter) error { +func (response CategoryUpdatedefaultJSONResponse) VisitCategoryUpdateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type PhoneSubmitCodeRequestObject struct { - AccountHandle AccountHandleParam `json:"account_handle"` - Body *PhoneSubmitCodeJSONRequestBody +type ClusterListRequestObject struct { } -type PhoneSubmitCodeResponseObject interface { - VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error +type ClusterListResponseObject interface { + VisitClusterListResponse(w http.ResponseWriter) error } -type PhoneSubmitCode200JSONResponse struct{ AuthSuccessOKJSONResponse } +type ClusterList200JSONResponse struct{ ClusterListOKJSONResponse } -func (response PhoneSubmitCode200JSONResponse) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response ClusterList200JSONResponse) VisitClusterListResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type PhoneSubmitCode400Response = BadRequestResponse +type ClusterList404Response = NotFoundResponse -func (response PhoneSubmitCode400Response) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response ClusterList404Response) VisitClusterListResponse(w http.ResponseWriter) error { + w.WriteHeader(404) return nil } -type PhoneSubmitCodedefaultJSONResponse struct { +type ClusterListdefaultJSONResponse struct { Body APIError StatusCode int } -func (response PhoneSubmitCodedefaultJSONResponse) VisitPhoneSubmitCodeResponse(w http.ResponseWriter) error { +func (response ClusterListdefaultJSONResponse) VisitClusterListResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type WebAuthnMakeAssertionRequestObject struct { - Body *WebAuthnMakeAssertionJSONRequestBody +type ClusterCreateRequestObject struct { + Body *ClusterCreateJSONRequestBody } -type WebAuthnMakeAssertionResponseObject interface { - VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error +type ClusterCreateResponseObject interface { + VisitClusterCreateResponse(w http.ResponseWriter) error } -type WebAuthnMakeAssertion200JSONResponse struct{ AuthSuccessOKJSONResponse } +type ClusterCreate200JSONResponse struct{ ClusterCreateOKJSONResponse } -func (response WebAuthnMakeAssertion200JSONResponse) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response ClusterCreate200JSONResponse) VisitClusterCreateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type WebAuthnMakeAssertion401Response = UnauthorisedResponse +type ClusterCreate401Response = UnauthorisedResponse -func (response WebAuthnMakeAssertion401Response) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { +func (response ClusterCreate401Response) VisitClusterCreateResponse(w http.ResponseWriter) error { w.WriteHeader(401) return nil } -type WebAuthnMakeAssertion404Response = NotFoundResponse - -func (response WebAuthnMakeAssertion404Response) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { - w.WriteHeader(404) - return nil -} - -type WebAuthnMakeAssertiondefaultJSONResponse struct { +type ClusterCreatedefaultJSONResponse struct { Body APIError StatusCode int } -func (response WebAuthnMakeAssertiondefaultJSONResponse) VisitWebAuthnMakeAssertionResponse(w http.ResponseWriter) error { +func (response ClusterCreatedefaultJSONResponse) VisitClusterCreateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type WebAuthnGetAssertionRequestObject struct { - AccountHandle AccountHandleParam `json:"account_handle"` +type ClusterGetRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` } -type WebAuthnGetAssertionResponseObject interface { - VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error +type ClusterGetResponseObject interface { + VisitClusterGetResponse(w http.ResponseWriter) error } -type WebAuthnGetAssertion200JSONResponse struct { - WebAuthnGetAssertionOKJSONResponse -} +type ClusterGet200JSONResponse struct{ ClusterGetOKJSONResponse } -func (response WebAuthnGetAssertion200JSONResponse) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response ClusterGet200JSONResponse) VisitClusterGetResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type WebAuthnGetAssertion401Response = UnauthorisedResponse +type ClusterGet401Response = UnauthorisedResponse -func (response WebAuthnGetAssertion401Response) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { +func (response ClusterGet401Response) VisitClusterGetResponse(w http.ResponseWriter) error { w.WriteHeader(401) return nil } -type WebAuthnGetAssertion404Response = NotFoundResponse +type ClusterGet404Response = NotFoundResponse -func (response WebAuthnGetAssertion404Response) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { +func (response ClusterGet404Response) VisitClusterGetResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type WebAuthnGetAssertiondefaultJSONResponse struct { +type ClusterGetdefaultJSONResponse struct { Body APIError StatusCode int } -func (response WebAuthnGetAssertiondefaultJSONResponse) VisitWebAuthnGetAssertionResponse(w http.ResponseWriter) error { +func (response ClusterGetdefaultJSONResponse) VisitClusterGetResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type WebAuthnMakeCredentialRequestObject struct { - Body *WebAuthnMakeCredentialJSONRequestBody +type ClusterUpdateRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` + Body *ClusterUpdateJSONRequestBody } -type WebAuthnMakeCredentialResponseObject interface { - VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error +type ClusterUpdateResponseObject interface { + VisitClusterUpdateResponse(w http.ResponseWriter) error } -type WebAuthnMakeCredential200JSONResponse struct{ AuthSuccessOKJSONResponse } +type ClusterUpdate200JSONResponse struct{ ClusterUpdateOKJSONResponse } -func (response WebAuthnMakeCredential200JSONResponse) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response ClusterUpdate200JSONResponse) VisitClusterUpdateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type WebAuthnMakeCredential400Response = BadRequestResponse +type ClusterUpdate401Response = UnauthorisedResponse -func (response WebAuthnMakeCredential400Response) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response ClusterUpdate401Response) VisitClusterUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) return nil } -type WebAuthnMakeCredentialdefaultJSONResponse struct { +type ClusterUpdate404Response = NotFoundResponse + +func (response ClusterUpdate404Response) VisitClusterUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type ClusterUpdatedefaultJSONResponse struct { Body APIError StatusCode int } -func (response WebAuthnMakeCredentialdefaultJSONResponse) VisitWebAuthnMakeCredentialResponse(w http.ResponseWriter) error { +func (response ClusterUpdatedefaultJSONResponse) VisitClusterUpdateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type WebAuthnRequestCredentialRequestObject struct { - AccountHandle AccountHandleParam `json:"account_handle"` +type ClusterRemoveClusterRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` + ClusterSlugChild ClusterSlugChildParam `json:"cluster_slug_child"` } -type WebAuthnRequestCredentialResponseObject interface { - VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error +type ClusterRemoveClusterResponseObject interface { + VisitClusterRemoveClusterResponse(w http.ResponseWriter) error } -type WebAuthnRequestCredential200JSONResponse struct { - WebAuthnRequestCredentialOKJSONResponse +type ClusterRemoveCluster200JSONResponse struct { + ClusterRemoveChildOKJSONResponse } -func (response WebAuthnRequestCredential200JSONResponse) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { - w.Header().Set("Set-Cookie", fmt.Sprint(response.Headers.SetCookie)) +func (response ClusterRemoveCluster200JSONResponse) VisitClusterRemoveClusterResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) - return json.NewEncoder(w).Encode(response.Body) + return json.NewEncoder(w).Encode(response) } -type WebAuthnRequestCredential400Response = BadRequestResponse +type ClusterRemoveCluster401Response = UnauthorisedResponse -func (response WebAuthnRequestCredential400Response) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response ClusterRemoveCluster401Response) VisitClusterRemoveClusterResponse(w http.ResponseWriter) error { + w.WriteHeader(401) return nil } -type WebAuthnRequestCredentialdefaultJSONResponse struct { +type ClusterRemoveCluster404Response = NotFoundResponse + +func (response ClusterRemoveCluster404Response) VisitClusterRemoveClusterResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type ClusterRemoveClusterdefaultJSONResponse struct { Body APIError StatusCode int } -func (response WebAuthnRequestCredentialdefaultJSONResponse) VisitWebAuthnRequestCredentialResponse(w http.ResponseWriter) error { +func (response ClusterRemoveClusterdefaultJSONResponse) VisitClusterRemoveClusterResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type CategoryListRequestObject struct { +type ClusterAddClusterRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` + ClusterSlugChild ClusterSlugChildParam `json:"cluster_slug_child"` } -type CategoryListResponseObject interface { - VisitCategoryListResponse(w http.ResponseWriter) error +type ClusterAddClusterResponseObject interface { + VisitClusterAddClusterResponse(w http.ResponseWriter) error } -type CategoryList200JSONResponse struct{ CategoryListOKJSONResponse } +type ClusterAddCluster200JSONResponse struct{ ClusterAddChildOKJSONResponse } -func (response CategoryList200JSONResponse) VisitCategoryListResponse(w http.ResponseWriter) error { +func (response ClusterAddCluster200JSONResponse) VisitClusterAddClusterResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type CategoryListdefaultJSONResponse struct { - Body APIError - StatusCode int -} - -func (response CategoryListdefaultJSONResponse) VisitCategoryListResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(response.StatusCode) - - return json.NewEncoder(w).Encode(response.Body) -} - -type CategoryUpdateOrderRequestObject struct { - Body *CategoryUpdateOrderJSONRequestBody -} +type ClusterAddCluster401Response = UnauthorisedResponse -type CategoryUpdateOrderResponseObject interface { - VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error +func (response ClusterAddCluster401Response) VisitClusterAddClusterResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -type CategoryUpdateOrder200JSONResponse struct{ CategoryListOKJSONResponse } - -func (response CategoryUpdateOrder200JSONResponse) VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(200) +type ClusterAddCluster404Response = NotFoundResponse - return json.NewEncoder(w).Encode(response) +func (response ClusterAddCluster404Response) VisitClusterAddClusterResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil } -type CategoryUpdateOrderdefaultJSONResponse struct { +type ClusterAddClusterdefaultJSONResponse struct { Body APIError StatusCode int } -func (response CategoryUpdateOrderdefaultJSONResponse) VisitCategoryUpdateOrderResponse(w http.ResponseWriter) error { +func (response ClusterAddClusterdefaultJSONResponse) VisitClusterAddClusterResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type CategoryCreateRequestObject struct { - Body *CategoryCreateJSONRequestBody +type ClusterRemoveItemRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` + ItemSlug ItemSlugParam `json:"item_slug"` } -type CategoryCreateResponseObject interface { - VisitCategoryCreateResponse(w http.ResponseWriter) error +type ClusterRemoveItemResponseObject interface { + VisitClusterRemoveItemResponse(w http.ResponseWriter) error } -type CategoryCreate200JSONResponse struct{ CategoryCreateOKJSONResponse } +type ClusterRemoveItem200JSONResponse struct { + ClusterRemoveItemOKJSONResponse +} -func (response CategoryCreate200JSONResponse) VisitCategoryCreateResponse(w http.ResponseWriter) error { +func (response ClusterRemoveItem200JSONResponse) VisitClusterRemoveItemResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type CategoryCreate400Response = BadRequestResponse +type ClusterRemoveItem401Response = UnauthorisedResponse -func (response CategoryCreate400Response) VisitCategoryCreateResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response ClusterRemoveItem401Response) VisitClusterRemoveItemResponse(w http.ResponseWriter) error { + w.WriteHeader(401) return nil } -type CategoryCreate401Response = UnauthorisedResponse +type ClusterRemoveItem404Response = NotFoundResponse -func (response CategoryCreate401Response) VisitCategoryCreateResponse(w http.ResponseWriter) error { - w.WriteHeader(401) +func (response ClusterRemoveItem404Response) VisitClusterRemoveItemResponse(w http.ResponseWriter) error { + w.WriteHeader(404) return nil } -type CategoryCreatedefaultJSONResponse struct { +type ClusterRemoveItemdefaultJSONResponse struct { Body APIError StatusCode int } -func (response CategoryCreatedefaultJSONResponse) VisitCategoryCreateResponse(w http.ResponseWriter) error { +func (response ClusterRemoveItemdefaultJSONResponse) VisitClusterRemoveItemResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) return json.NewEncoder(w).Encode(response.Body) } -type CategoryUpdateRequestObject struct { - CategoryId CategoryIDParam `json:"category_id"` - Body *CategoryUpdateJSONRequestBody +type ClusterAddItemRequestObject struct { + ClusterSlug ClusterSlugParam `json:"cluster_slug"` + ItemSlug ItemSlugParam `json:"item_slug"` } -type CategoryUpdateResponseObject interface { - VisitCategoryUpdateResponse(w http.ResponseWriter) error +type ClusterAddItemResponseObject interface { + VisitClusterAddItemResponse(w http.ResponseWriter) error } -type CategoryUpdate200JSONResponse struct{ CategoryUpdateOKJSONResponse } +type ClusterAddItem200JSONResponse struct{ ClusterAddItemOKJSONResponse } -func (response CategoryUpdate200JSONResponse) VisitCategoryUpdateResponse(w http.ResponseWriter) error { +func (response ClusterAddItem200JSONResponse) VisitClusterAddItemResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type CategoryUpdate400Response = BadRequestResponse +type ClusterAddItem401Response = UnauthorisedResponse -func (response CategoryUpdate400Response) VisitCategoryUpdateResponse(w http.ResponseWriter) error { - w.WriteHeader(400) +func (response ClusterAddItem401Response) VisitClusterAddItemResponse(w http.ResponseWriter) error { + w.WriteHeader(401) return nil } -type CategoryUpdate401Response = UnauthorisedResponse +type ClusterAddItem404Response = NotFoundResponse -func (response CategoryUpdate401Response) VisitCategoryUpdateResponse(w http.ResponseWriter) error { - w.WriteHeader(401) +func (response ClusterAddItem404Response) VisitClusterAddItemResponse(w http.ResponseWriter) error { + w.WriteHeader(404) return nil } -type CategoryUpdatedefaultJSONResponse struct { +type ClusterAddItemdefaultJSONResponse struct { Body APIError StatusCode int } -func (response CategoryUpdatedefaultJSONResponse) VisitCategoryUpdateResponse(w http.ResponseWriter) error { +func (response ClusterAddItemdefaultJSONResponse) VisitClusterAddItemResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) @@ -9744,36 +12424,194 @@ func (response IconUploaddefaultJSONResponse) VisitIconUploadResponse(w http.Res return json.NewEncoder(w).Encode(response.Body) } -type IconGetRequestObject struct { - IconSize IconGetParamsIconSize `json:"icon_size"` -} +type IconGetRequestObject struct { + IconSize IconGetParamsIconSize `json:"icon_size"` +} + +type IconGetResponseObject interface { + VisitIconGetResponse(w http.ResponseWriter) error +} + +type IconGet200AsteriskResponse struct{ AssetGetOKAsteriskResponse } + +func (response IconGet200AsteriskResponse) VisitIconGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", response.ContentType) + if response.ContentLength != 0 { + w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) + } + w.WriteHeader(200) + + if closer, ok := response.Body.(io.ReadCloser); ok { + defer closer.Close() + } + _, err := io.Copy(w, response.Body) + return err +} + +type IconGetdefaultJSONResponse struct { + Body APIError + StatusCode int +} + +func (response IconGetdefaultJSONResponse) VisitIconGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type ItemListRequestObject struct { +} + +type ItemListResponseObject interface { + VisitItemListResponse(w http.ResponseWriter) error +} + +type ItemList200JSONResponse struct{ ItemListOKJSONResponse } + +func (response ItemList200JSONResponse) VisitItemListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type ItemList404Response = NotFoundResponse + +func (response ItemList404Response) VisitItemListResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type ItemListdefaultJSONResponse struct { + Body APIError + StatusCode int +} + +func (response ItemListdefaultJSONResponse) VisitItemListResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type ItemCreateRequestObject struct { + Body *ItemCreateJSONRequestBody +} + +type ItemCreateResponseObject interface { + VisitItemCreateResponse(w http.ResponseWriter) error +} + +type ItemCreate200JSONResponse struct{ ItemCreateOKJSONResponse } + +func (response ItemCreate200JSONResponse) VisitItemCreateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type ItemCreate401Response = UnauthorisedResponse + +func (response ItemCreate401Response) VisitItemCreateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type ItemCreatedefaultJSONResponse struct { + Body APIError + StatusCode int +} + +func (response ItemCreatedefaultJSONResponse) VisitItemCreateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type ItemGetRequestObject struct { + ItemSlug ItemSlugParam `json:"item_slug"` +} + +type ItemGetResponseObject interface { + VisitItemGetResponse(w http.ResponseWriter) error +} + +type ItemGet200JSONResponse struct{ ItemGetOKJSONResponse } + +func (response ItemGet200JSONResponse) VisitItemGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type ItemGet401Response = UnauthorisedResponse + +func (response ItemGet401Response) VisitItemGetResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil +} + +type ItemGet404Response = NotFoundResponse + +func (response ItemGet404Response) VisitItemGetResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil +} + +type ItemGetdefaultJSONResponse struct { + Body APIError + StatusCode int +} + +func (response ItemGetdefaultJSONResponse) VisitItemGetResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type ItemUpdateRequestObject struct { + ItemSlug ItemSlugParam `json:"item_slug"` + Body *ItemUpdateJSONRequestBody +} + +type ItemUpdateResponseObject interface { + VisitItemUpdateResponse(w http.ResponseWriter) error +} + +type ItemUpdate200JSONResponse struct{ ItemUpdateOKJSONResponse } + +func (response ItemUpdate200JSONResponse) VisitItemUpdateResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type ItemUpdate401Response = UnauthorisedResponse -type IconGetResponseObject interface { - VisitIconGetResponse(w http.ResponseWriter) error +func (response ItemUpdate401Response) VisitItemUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(401) + return nil } -type IconGet200AsteriskResponse struct{ AssetGetOKAsteriskResponse } - -func (response IconGet200AsteriskResponse) VisitIconGetResponse(w http.ResponseWriter) error { - w.Header().Set("Content-Type", response.ContentType) - if response.ContentLength != 0 { - w.Header().Set("Content-Length", fmt.Sprint(response.ContentLength)) - } - w.WriteHeader(200) +type ItemUpdate404Response = NotFoundResponse - if closer, ok := response.Body.(io.ReadCloser); ok { - defer closer.Close() - } - _, err := io.Copy(w, response.Body) - return err +func (response ItemUpdate404Response) VisitItemUpdateResponse(w http.ResponseWriter) error { + w.WriteHeader(404) + return nil } -type IconGetdefaultJSONResponse struct { +type ItemUpdatedefaultJSONResponse struct { Body APIError StatusCode int } -func (response IconGetdefaultJSONResponse) VisitIconGetResponse(w http.ResponseWriter) error { +func (response ItemUpdatedefaultJSONResponse) VisitItemUpdateResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(response.StatusCode) @@ -10347,6 +13185,30 @@ type StrictServerInterface interface { // (PATCH /v1/categories/{category_id}) CategoryUpdate(ctx context.Context, request CategoryUpdateRequestObject) (CategoryUpdateResponseObject, error) + // (GET /v1/clusters) + ClusterList(ctx context.Context, request ClusterListRequestObject) (ClusterListResponseObject, error) + + // (POST /v1/clusters) + ClusterCreate(ctx context.Context, request ClusterCreateRequestObject) (ClusterCreateResponseObject, error) + + // (GET /v1/clusters/{cluster_slug}) + ClusterGet(ctx context.Context, request ClusterGetRequestObject) (ClusterGetResponseObject, error) + + // (PATCH /v1/clusters/{cluster_slug}) + ClusterUpdate(ctx context.Context, request ClusterUpdateRequestObject) (ClusterUpdateResponseObject, error) + + // (DELETE /v1/clusters/{cluster_slug}/clusters/{cluster_slug_child}) + ClusterRemoveCluster(ctx context.Context, request ClusterRemoveClusterRequestObject) (ClusterRemoveClusterResponseObject, error) + + // (PUT /v1/clusters/{cluster_slug}/clusters/{cluster_slug_child}) + ClusterAddCluster(ctx context.Context, request ClusterAddClusterRequestObject) (ClusterAddClusterResponseObject, error) + + // (DELETE /v1/clusters/{cluster_slug}/items/{item_slug}) + ClusterRemoveItem(ctx context.Context, request ClusterRemoveItemRequestObject) (ClusterRemoveItemResponseObject, error) + + // (PUT /v1/clusters/{cluster_slug}/items/{item_slug}) + ClusterAddItem(ctx context.Context, request ClusterAddItemRequestObject) (ClusterAddItemResponseObject, error) + // (GET /v1/collections) CollectionList(ctx context.Context, request CollectionListRequestObject) (CollectionListResponseObject, error) @@ -10374,6 +13236,18 @@ type StrictServerInterface interface { // (GET /v1/info/icon/{icon_size}) IconGet(ctx context.Context, request IconGetRequestObject) (IconGetResponseObject, error) + // (GET /v1/items) + ItemList(ctx context.Context, request ItemListRequestObject) (ItemListResponseObject, error) + + // (POST /v1/items) + ItemCreate(ctx context.Context, request ItemCreateRequestObject) (ItemCreateResponseObject, error) + + // (GET /v1/items/{item_slug}) + ItemGet(ctx context.Context, request ItemGetRequestObject) (ItemGetResponseObject, error) + + // (PATCH /v1/items/{item_slug}) + ItemUpdate(ctx context.Context, request ItemUpdateRequestObject) (ItemUpdateResponseObject, error) + // (GET /v1/posts/search) PostSearch(ctx context.Context, request PostSearchRequestObject) (PostSearchResponseObject, error) @@ -11070,6 +13944,218 @@ func (sh *strictHandler) CategoryUpdate(ctx echo.Context, categoryId CategoryIDP return nil } +// ClusterList operation middleware +func (sh *strictHandler) ClusterList(ctx echo.Context) error { + var request ClusterListRequestObject + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterList(ctx.Request().Context(), request.(ClusterListRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterList") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterListResponseObject); ok { + return validResponse.VisitClusterListResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterCreate operation middleware +func (sh *strictHandler) ClusterCreate(ctx echo.Context) error { + var request ClusterCreateRequestObject + + var body ClusterCreateJSONRequestBody + if err := ctx.Bind(&body); err != nil { + return err + } + request.Body = &body + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterCreate(ctx.Request().Context(), request.(ClusterCreateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterCreate") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterCreateResponseObject); ok { + return validResponse.VisitClusterCreateResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterGet operation middleware +func (sh *strictHandler) ClusterGet(ctx echo.Context, clusterSlug ClusterSlugParam) error { + var request ClusterGetRequestObject + + request.ClusterSlug = clusterSlug + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterGet(ctx.Request().Context(), request.(ClusterGetRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterGet") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterGetResponseObject); ok { + return validResponse.VisitClusterGetResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterUpdate operation middleware +func (sh *strictHandler) ClusterUpdate(ctx echo.Context, clusterSlug ClusterSlugParam) error { + var request ClusterUpdateRequestObject + + request.ClusterSlug = clusterSlug + + var body ClusterUpdateJSONRequestBody + if err := ctx.Bind(&body); err != nil { + return err + } + request.Body = &body + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterUpdate(ctx.Request().Context(), request.(ClusterUpdateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterUpdate") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterUpdateResponseObject); ok { + return validResponse.VisitClusterUpdateResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterRemoveCluster operation middleware +func (sh *strictHandler) ClusterRemoveCluster(ctx echo.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) error { + var request ClusterRemoveClusterRequestObject + + request.ClusterSlug = clusterSlug + request.ClusterSlugChild = clusterSlugChild + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterRemoveCluster(ctx.Request().Context(), request.(ClusterRemoveClusterRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterRemoveCluster") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterRemoveClusterResponseObject); ok { + return validResponse.VisitClusterRemoveClusterResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterAddCluster operation middleware +func (sh *strictHandler) ClusterAddCluster(ctx echo.Context, clusterSlug ClusterSlugParam, clusterSlugChild ClusterSlugChildParam) error { + var request ClusterAddClusterRequestObject + + request.ClusterSlug = clusterSlug + request.ClusterSlugChild = clusterSlugChild + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterAddCluster(ctx.Request().Context(), request.(ClusterAddClusterRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterAddCluster") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterAddClusterResponseObject); ok { + return validResponse.VisitClusterAddClusterResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterRemoveItem operation middleware +func (sh *strictHandler) ClusterRemoveItem(ctx echo.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) error { + var request ClusterRemoveItemRequestObject + + request.ClusterSlug = clusterSlug + request.ItemSlug = itemSlug + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterRemoveItem(ctx.Request().Context(), request.(ClusterRemoveItemRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterRemoveItem") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterRemoveItemResponseObject); ok { + return validResponse.VisitClusterRemoveItemResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ClusterAddItem operation middleware +func (sh *strictHandler) ClusterAddItem(ctx echo.Context, clusterSlug ClusterSlugParam, itemSlug ItemSlugParam) error { + var request ClusterAddItemRequestObject + + request.ClusterSlug = clusterSlug + request.ItemSlug = itemSlug + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ClusterAddItem(ctx.Request().Context(), request.(ClusterAddItemRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ClusterAddItem") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ClusterAddItemResponseObject); ok { + return validResponse.VisitClusterAddItemResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + // CollectionList operation middleware func (sh *strictHandler) CollectionList(ctx echo.Context) error { var request CollectionListRequestObject @@ -11305,6 +14391,114 @@ func (sh *strictHandler) IconGet(ctx echo.Context, iconSize IconGetParamsIconSiz return nil } +// ItemList operation middleware +func (sh *strictHandler) ItemList(ctx echo.Context) error { + var request ItemListRequestObject + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ItemList(ctx.Request().Context(), request.(ItemListRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ItemList") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ItemListResponseObject); ok { + return validResponse.VisitItemListResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ItemCreate operation middleware +func (sh *strictHandler) ItemCreate(ctx echo.Context) error { + var request ItemCreateRequestObject + + var body ItemCreateJSONRequestBody + if err := ctx.Bind(&body); err != nil { + return err + } + request.Body = &body + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ItemCreate(ctx.Request().Context(), request.(ItemCreateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ItemCreate") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ItemCreateResponseObject); ok { + return validResponse.VisitItemCreateResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ItemGet operation middleware +func (sh *strictHandler) ItemGet(ctx echo.Context, itemSlug ItemSlugParam) error { + var request ItemGetRequestObject + + request.ItemSlug = itemSlug + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ItemGet(ctx.Request().Context(), request.(ItemGetRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ItemGet") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ItemGetResponseObject); ok { + return validResponse.VisitItemGetResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + +// ItemUpdate operation middleware +func (sh *strictHandler) ItemUpdate(ctx echo.Context, itemSlug ItemSlugParam) error { + var request ItemUpdateRequestObject + + request.ItemSlug = itemSlug + + var body ItemUpdateJSONRequestBody + if err := ctx.Bind(&body); err != nil { + return err + } + request.Body = &body + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ItemUpdate(ctx.Request().Context(), request.(ItemUpdateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ItemUpdate") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ItemUpdateResponseObject); ok { + return validResponse.VisitItemUpdateResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("Unexpected response type: %T", response) + } + return nil +} + // PostSearch operation middleware func (sh *strictHandler) PostSearch(ctx echo.Context, params PostSearchParams) error { var request PostSearchRequestObject @@ -11634,145 +14828,178 @@ func (sh *strictHandler) GetVersion(ctx echo.Context) error { // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+x963LjuLHwq+Bjvqo9JyVZM7PZJOWqU3W842TX2YunbE/yYzXlgciWhDUJMABoWevy", - "u5/CjQRJkKIoeW6bPztekWw0uhuNRt/wGMUsyxkFKkV0+hjlmOMMJHD9f2dxzAoqv8c0SeGNeqR+TUDE", - "nOSSMBqdunfQWr90Ek0ieMBZnkJ0GglWyHWc4o2IJhFRb+dYrqNJRHGmnmPz7a35NppEHP5dEA5JdCp5", - "AZNIxGvIsBr0/3NYRqfRH2YVvjPzVMxqaEZPT5PoTAiQb9RYbXzVI3RxfhJGiSS9aMhtricmOaErPdRr", - "LGHF+PbivINAbyn5dwEotu91D+3euN2BQx8pLhKgkiwJcIMcS1OIFSI70Svf7EGwfOeoKFIJVP4IdBVi", - "17cs2aLYvINS/RIiFC22EkSJ5hpwArxC1MKcWqADGEqLbGERuogZvSa/QRsX9QQJ8psZuRLzb16+evjm", - "5asOgYoZvVUf9aIBtMii0188UF+/evha/fvyry8eXv71hfrr1YuHl6/0X3/+y8PLP/9F/fXNq4eX37yK", - "3k0Conl5Vsj1G87uiaJOazo3a0CkZAZaMo4wRfqjVyi3nyFRxGuEBZpHckOkBD6P6rO3P4dnz3Ah17cO", - "2J5L6w0Tcpfc5kz0rGb19IiyerPmgJOfML/rQMq8gAqDG6YJyoFnWAH1SN2BrNQf32aY341GuMIwelIY", - "Kygg5LcsIeCr9GuQZ/dYYi0WdnmpP3GepyTGajozFkuQUyE5mKlWGCwZz7CMTqMFoZhvo7bwaSVshnqb", - "J1hCzzi/CkW7x/2U/U+FxIsU3nCWCzdekhF6DVISuhLHHtWHHRpb7Spv85Th5LkoOmkuAD0awmhJ1L6r", - "kFDLHQuxYTw53sw1UMLtRN1295rDMelb7qKUSIJTn7Tu0ZE56sAGmFkf8ZJb7XnciZba4EcipBu43GCP", - "Td7KDggQuHx4bBKXgANErm1Or3GaLnB8d7ShNfQSqhnxzZpRuDIK8TVLjjfPJmB/mvrZdbHIyDOMWcGt", - "DcmEPLL86J24ITlNfWSGRNhsyRsi14QijMyupvWTgnIFOJZnSXJU1DTQTsTOEqUluXpHmbeSWRxLnI4s", - "9gpkU+D3J5bZyY/MRwM0oAPMgyMTwhoj7bX/L1io9Ul/wnegdk5uqHIs+heLlMQ/gNqjtJbFaWBc7+Fz", - "D6ztMJEzKmo2mK8A1SZw+cOxjSQ1wk8g1ywJCuHlD1Flpn3XYRGSDK9gltPVwQZLc7jjz3fnqHZH/5AD", - "t43SYw7vQ+9UNhYTZaKGyP7H2R8P5q06S1LYoLdXPyK2VOfIQpunkHjmaWUjH5MECupolA5bgjlnuVJe", - "Zlm7U64YZFJ7o0bupGbOe794kKpzPVv8CnGfoBVyfV3EMQhxTOpWUDuGnljvi571Ncjpa8buCNSHCB0P", - "v8WJtZkCXh+cIHt0jVqHjiNOzwHuJqt748gK2ge7e/Cj640B8y5t97MkURbNMUcvYQdNo8oT6fx+OEnA", - "WEXNE9JHwUqP3MTnuBtaBfdfRK4vJGRiB1aEGrWt/sY0cbRrYHmwkqt8wGL4HIJKzoc0RM15c02JaE7s", - "CjJ2D5+ioB5/8Q7FqtAjG3y+A3lBl+yIaChw3frjgkrgFKfXwO+B/41zdjwfytmbCwMwMLobF5mBkX1x", - "Ev3M5N9ZQZP2ZvMzk2ipH9UOz0cklQLaaZ1Zn7E+CFrVgoTZcpdFmm5bR+cjIqZBhpBS41VH5kqs1e/X", - "gHm8PjJ5DNArEEUqd5LJCnaYTEdfb4O5140WZ8rkPO4WYU6bFnT3QvT9CEcc3YDtoYi/S5qfvgP5QYaH", - "+l64YIUsXSt6ayRSaIYJD7mDN0YDXwxDPLghOghDNkMFQJ9q0tTOzJ/M0ZfATm77W81bigu5ZpwISEJx", - "O/v0N9AK1/lkvgNZuoKOuVmWrhh72LjMjclx5NOMm4ZzA5fDHnEubgzfz6ThPMucnlzM0fis3J7bTqhA", - "3v/bkzaoVxGhcVokhK4QRusiw1TtKAlepIAyEAKvTIgU0+2ccki17sxA4gRLjJacZUiuwZ0DzatCsJgY", - "JQv8nsQgTuY0mjTWIoQxNarB2gf6nQmiTOrfqPYLMI6AJtNCAEcJEXmKtydt98cksuiHiKEnOm1NdMwY", - "hhJaZpKEqBGM09ZN1ASGGwjQLarersjp6CuZJqqevTes0zSTSBSrFQgZWrpnqHyIrGWgZqPgqdkEZtHQ", - "cIYv7wKjOj+ammuaXi6j0192GcFZxqhHjafJIE9d9Z2InnowqVynw3GqpVsMxKcaZx+c9P5x+hgRfTDc", - "1xmsQNoxMOd4GxzCoNPa5hTf7wOCf8MLQGSphcGmdSEiUCHU8pdrIpBS+0oe1yzxJGXBWAqYtkTFjjOI", - "GiE0C7m+zaqne9EnuDvXIPag5QtYG60kI9RTt+XsJ9GCsIAenkQ2N26/FLhJpPUcCLnbIMErM1+XhzJo", - "oJ/Vq00SlWl8GtDEzvZdRZvvy7m0FbPNmflfm0hoNxIrSvWMo2s/rbBOsEn0MF2xaYuKoayRFnc+Mgsu", - "zsVYLnQJ488WVpvcbo2yDQUu3EaE1OB1Yn+LOcWLLfoBgEJon+pOjQkojxiovI1ZygoeJHUN0cBzSaTh", - "RHujadOgHRxpkeJaMr5NgCJChcRpWvnPtPASIbn5SVg4Jy1j41knVTsf6Nfq4CaN4YOKSUdIWsxYA1mt", - "ZSAHchKRZFDU5eJc2ykkg1sDIjC3gqfB3zckMeme7QRMf846d0/B8MdxX0/cHDpnfXEesmKsqmnkPupN", - "ioNgBY8bayCOv0lp8kq8FH/68zevcCKLb15EkypO9qDRHKiJFF777d8mwhXYs6UEIbV8vmb0HraYxvCG", - "wxI40Diw8NdS5uJ0NttsNiebr08YX81urmYbWKjNjU5fzf4AtMimuII7jTVgbWO7HNWEcEVj9YMEnqtz", - "nk5oLH+njEIgI9UlqBHeFsaKF9p+LynPEkJDSkeyO6D1V3OX+bbLCvXGcoCCAtRInq0jnBJ6F9as620O", - "XD1WtjZXRj/fZSZPopSt2K1dK22Q6qmC5rS0A+fihEGQtFP3N44o6kW13e6EmPemEou0WA2F1RHvrEyH", - "kh4TQ+ldDNpvQdXt9Pa68oKeAUndralJ0omwEj1z+P/bgwQq1Ln9dUqAyguaF1Lsd9rbvaATEssEllNc", - "GxvKsWM9NtFjz2nUjzXjZ1LieJ1ZV8YY7dJAhnFcgqxpmTzFUinYaBLFnAkxLX/o0iwlxCubbDMGxRpq", - "Lmsn4GLwdOSlIVVol6tBO7eH+dZbhgfq8T+uL38OviLIimJZ8PAmKzmmImfciE+5BtrvNQRdqaPKJu+X", - "6QaS73ZJyjWUgVoigRM8hhsB6WVcOMixhRxiT7fQ7tIMoc8qWlyB0PvHD7ANn+N4/YX+6Ev56pWB7gZT", - "jPkncLK063UXpLeN92vgAgfZ0BzrqIf4W2YNPJ+Xpsz08N00A785K9Vm2IsSeK+dw8OEfO08URaCOset", - "ArZp9W7faGP9AQecJzKQO33JPznv4sATp5uOOXJOIrXbD/3mWr2rvmF8CF2tCaBHaJ52LFUsLOdisFPu", - "Y0Mj336oqeAXALX1Z7Bq4XfN5DArO3ho/UM9XHO8auSgmKfOIBvCxyrhqcnF5jZXwe5DbIef4/fF8U4q", - "hd1PZ2Ut7FdCn4imSxwTuiqdT62ZO3hX/tH2Q+5AfaJwbUnWM8m3Vz9OBV6aM1LvDBUwJ/RNgKmN+ZaV", - "xIpepgh2nyXgtHFLmVVpRc9I3Sp/r0HfFvm81DaBMFpxVuTmaKnD3dpzmaDFFmFzrEYXEuE0ZRsjVAJJ", - "NqdxwbEEdRwlXH2hiSg0FW3KVhlnFETCCaoQFCjGFDGabudUvYwJRZwxiVK4h9QkEKD/stj8t67hQNpF", - "J7T/ULFa4YCsK+AkfLoKEyTA/dKt40J4FYFa1u8uTeI0Q+uB9gbvTDwxKSfVYhyk9Q3od70k6N9HR85q", - "N3I7kJKQfZAVoQaqr4oWHv3GpM6r2J97k0isrWXWiveqB+geuLCxfSV4RuS/EmjBki2S8CC1Q6oQgAhF", - "OYd7AhtRk3fvIDtgg/GLmD3veNvlpB/V0ao7br+HNGVow3ia/L+dXihLv9LydP52Q53dQrKXYdmQr159", - "PBJwP9B+C2b8WushUpXK/ME3mEnLjbc/k4JhYQPnXXsHU/K5LNIUVePqmKantyd63RgXscmSEYSuUl+1", - "z6lgGWzWwAGZ/25ZoTcmvFwyrvM5xJptbCIYII2PWof1LcKsxgDiQYY1aN42wE1u35nsWpYZ2NQdE01B", - "GyyqhEAvcJJgCVP1ekhVJJDC3qMItpRT++XwoXYHvOoHwYyIOKAv+YJIjvkWwYPkGOnEGyEZh8SaBx62", - "weQbm0a335TL3Lthsw1F2CqG+jiEhUObTT8Qk0ldemuZUN8aHRz00Hof7rMAq9FC2qwruW+Eq1HEkk7j", - "EqDNOmMG4LR0mAd8jblLxxtRH9pKSmy4mErQIV5c1IJmn1SUUxcHBMq6BImRmVQgSVdJdjAg/xxBd0YX", - "DPOE0NWtkFgWO2Xxsvzg2rx/3Mh9CKMQ038alxZYqqYqwdIGEXsVUr2PQqAaKAkfJNQEBhDGvDYxcEKz", - "bRG9JVPnwMk9JOYcZzUuljBBhCZEHZUF2qyxVL/qNEw954rUanuOQYg57ZQ+df4kJtXRhLjVZ0vChdQa", - "FgmQRY6EhNwavU4p2pmKW/3yrU25qfZhceuO8v5vGePg3hX+AwPFaloloGqTC+racEOK4JaSq1eRyb4o", - "U21zvE2ZsaX7wvRtaAkIxVp9ANeh4Or8a0LC3mg9reLakWf13a3NEdk9Dx14j4Hcg+W22QuREjNk1Mke", - "KQK1wUNCGuzFEcRSv4mEftVg00nqjqXVKqLrWDi6jqn3tCgEyGG5Jy4/cPwBU50Uh5TZ2P1+jLdTFyuJ", - "QQVPbj4c8nR7K9l+th9nTPcU2/+j/c++NiOkN/R39WNLKhyK/riWCZPqmGspNnGi0C1GZe1CW6IrH4A+", - "3ATbmSBtu25zUJoUiFwDV2cdLdGI8TnFFJkhJyiBHKhWzIwaxa1NXAEJSgr9QWyLHk7QtYZg/HQLmFP9", - "llLTC2NnpFipe40bRxnmdwnbeLWaNLGjCoQ5IPf1nCoNjIyCfdB4i7IL3nWKJZz8KhAkRKoNgcVFpvjR", - "4e5oNc5pJ51+iKUxRs5Hyp6eT5co1YyXkQ6ATtj9ub3PT+Y9CBacQIn5MMrU6LnLLdLcDkIedwqb4PpV", - "K9uUy6Ez80KGt0gLlW6mRJle0foJocaQsl8utkjkEJPl1pQBAHrvhPG9c4xsjX7wzinGSJtT7917nBaA", - "skJItIAaltp1r00No2zCbvZGl6iWKruypa5GFcQF50BlukW/qhEFUarAKiyBFuaostVkIFnO2T0gpRd4", - "sBYpY7+Sga6ydiFswOKuJydUSbu8+mTQ2dora90VEy3NVjNCcAU2d/3AiTQjlGQ4rYcy6kn+g+OoY3Py", - "99y3Dy2J0JtwR11EiIqBDlIjfBlkiWOY5neVO2O/FKmODLUyY9GTztYUgvmRk4jjzUXHEy9bb3BuVpni", - "V8ru4xA/l8HCG9N+PZAXzXrLvVgD9ZQ24wW5g23FJGfZWKdTf9bhTnLtSA5vZieW+Xp78aGd5aekZY3T", - "FOgq7BqAhzgtEq//2h4qq82Sc0t/FkzQqfJc95hVd26uOokWCzu+bgF8EO5vqmbrAdx5PsafmP+NSiJN", - "ngvJgBXBjCuTYTgC/lsB3I3QPHTkkQXrS0CQ3wEyDlyBHrsPSCcNrL2kBBxYdh06rSPt1rl/FqmpizAF", - "x0r9L2NNooWiEDaP19sFJ2GPeVMgnJ7bk2U36rOWR9LU0XQkqvfL6nEJX904ENJ36Spo6zwDKdRQA2lx", - "eLChhx71wEOQJinbfBDt2a/Hed6xoe/UO83M5qqwSMSs4HgFiZ612qs41Lq3v9vluatwHspMpzGPzMYc", - "NNjh2mSv9JXhC/fGLpWxtRqBualh67Ua+p3pXS1O5TlBeveR49JdyVcn5W391M9d6U8HcUYbmC67yBuo", - "m0+ud89h2RDDaphrIfujVThnuEM5fIzy8+BZy49sV0i9C3qRTDes1pG76wS/72nyqWvIXQmfvHRO6Oit", - "9n6ssUBrbMNeObDc3L0zaCOwXb/aCr+jIOUA7eFKSu5gyyuIjXLSEVp/Et3gYNatxCu0WZN4rb3COvaU", - "m2UmkA54muTRe4JRKQ6h4EtnXPk5PAg3eNUt0bRLibil0yM5Eq+GJwgrigaEwutOsGMkdHE+fLT+ygpH", - "kWDMwRWZYjVqMJ3a9qsarFjN+37IKlQY9By+tTLJ0MRoTK7hJMoJpXoNlNEaRWD1QOMxiWqRYx3HaYvI", - "u5ISRw9BxF4p2B5pU3t61IclZpgpekkZilJ7tdwo0zh2D3OjXx0fHnH8tsE4j409OR9e07ihEtiW6PYa", - "q0KNIUXqsnwvzk2oLLctpXSdtwB1bpMuAT/BYo3+BxH5lXB5RxnmdydzeqNb/5i0fKBJzgiVwgToRc6o", - "TmC8x1zHB5aMZzZJ0hv9ZE7n9O+MI5ssMEErcg9eeKJMrbs4R+9DSUzv9QR0SEEj/16yfPryxTRj9wTE", - "1IB5P6myPzYkTVFBE+BCqk8XzI6gMTyd0+Aw0yBYPXYYrTlFWJiszWaSFpa1eEZ/klZw4Ebm1lRtrOQB", - "kukdLPBiGmMB0zKJa1hSV+A+h//okg+sSzp0w7Eqoz5ijshQMWgXg5myurFtqfcXJbs5t5Tmv9agI6Fe", - "AFSZ6/ptE9QkoqzeCvVAM9v7bRnjC5g+JsHJRWSNkjKAq/oH9e8lTbcuFbDthRmRLPN8NSId6B5UM2KX", - "ba+16jWTLLeQiojDuyg8X4HKwVbGPlblrQvztk1Lu0TKTKHJjubtgeQCux6q0K9pDgoCZczypL9x76KQ", - "c5owELZlp/7aJBXqleClA7i0o7cClkXaKLJIMV/BnJZ1gGU5IUcmj0EQWWBz3N6sgeqCi4TRrySiAIkx", - "A4o01bmmSoBLHdyVoVpO3uQpIZ1akXC8lCZVVZ1XU5upuKHAUYbvQKB4jekKRFXuZ/r5o0sdOF/DVqcq", - "rHGeb438Ejkxv6txtGtMNIW6PHOr0U0YRr3VdcT2dql+8cajhFtJboBaG1ggnCQchPCNGNMNqA2kp/WF", - "Br7ERaq+9z0LY90ZhdBd5cvBjuzT2Nng9/C6hkaM+dkKG9qtiYdXNiiVD3HBidxeqxGsZcnZxgYt9eWp", - "seliXF6fKqz1PhUghMmwd5o6J2qgp0nkCLMbSEnCTmhP2s1pyhx0fbDxHVpA9baJrbbM5VFDb0EpOntz", - "YTIXC5Lq7MeYZVlBidyihOvjjmt/pD0sdssp0Y0mkd2Ao9PopS5vyIHinESn0dcnL05eKt5iudaEnNln", - "J6779Apk8FYEONXqYwUUOJaM2xIugTB6n+H8FyO477QfbYljeHx6b1rAEqEMHwFS12C/b3a8fn9ycoIE", - "QxdfZSbBynSJ9fI1FSko2xj7QImk/vgiiU6j70Be5xBHjTvVXr140eizrQDNNMwdna5DffM9EYxOf3k3", - "iUSRZVgZpwoBTZbLHKhi29cnL2ySm52jOtT94/ry5xO3v57+YgrG3imws/uXszK7v4v4bgx/P3T1GlVy", - "mpe/oTsyl1lUdYpVN651EC20tMv3ZrUL254m0Z9evNz9Ua0HvP7oT7s/Kq/o0CyxenvXR6GLRp6eKsqX", - "tH73pNdAHLhk3PTLPzrF7XWK/i3M2+4JeRc1z+oAng5gW3kVwGfNuca6mQlIlzOF59Tr8RxcSVcgOYF7", - "QLg0/uut8Mo2hcaERBgtU7xy1UNKL+lwwpwyCiY71LSmHiwdAR3WcQHkIcszcJOdZt4ACN5FbMdgX11v", - "DmZmefekLnAKLFFz2zVF5s2S/Pstyerec6UMqpSWDl9J9YorRf0R6Equ9RFn7KqucOhY2KFrXL6ctfto", - "/7o1odonj/Wde2Gb7XbHHbbvjWR5Ld5tbvw3fB+/hVaM/0wYOng1u1Tt/i2WMjoFeq9Os0uyKhrNtTV3", - "m4W/DaYGLvkfsxQDYMZts8H7Xcep3lEicbwla7v1O4aWvt8dCjlxJbQIowwSgu31qi3OVde/fhTl6w0/", - "jtO162s/Prts0V6dX7NHkjx1qtJztqHlNqreR4utvg3r4ryDX+bQsKfaVB++wSWjRhH6cztudOjJJpMK", - "0/T+UFP1pIpViiLXKcjKcIUNmtMN3mqnoW8YTUyekC1kcp3S9Wu6wl8vY+d9OkE3ayLm1IVrkYQ0VfBN", - "FYhNr9HXucQ4xwuSEt3dRtnGQPEihSRo9B7F2v3UzVzF4Bq7Zylb2WzYDq5n7B6QcUQJwyerubQfSNP8", - "pJ+aZoSBxuToK84+BpV76Mr0fx/1P7duZTzNYr9ZRXDnuiYrqsNxuvgMHoihtLsRxZ4CyxYGeoezK6bN", - "h0ufEWWjjH1V5mW9Jf2Y/S2MyNPYRVZdJf7Z6+C26Dh2zgRZUWu2Pr+omNsvzNNrM/AYO8aD8h/27mZv", - "kXez9wpWREjdjYDC5khsLfJPhq2f8K6om6r0LDyJuWz6d7RPNmUbx6BaNxldRG5cCtwkcAmgyZziRvsX", - "14nGaMqk3jjGmDa6zFyNihagoJgwho7Pmkp3/UllHjGkY4JbDdhCUjJzj1NSOpZ73IHNdj1j5KcF4/ci", - "Qy1/kolcBmTqtW2Z1OpEFJSxxdb26ZGudYGTozk1guSak1gJKS/4+UoY6J2srloFHc8lNUZcPDx+B9Li", - "Irr6pGxSmcK6pyYnVeQcYXc9senvXDMNOp2Q7lD1E76D8n7jMQs8DOj3agA8eqH8X0w1z2DOBzVG8GxW", - "7UKO+p4QLBkPGYXdIuDfcP3xfNEd921/gWZgyfYM38GA5V7ymGuz0PqmF1vbcUo36FVmYqUS+pe718Pj", - "wPXuQfoiFPW41avYeNDarfHVOa0XW9/dgn3uBvbvzmveP/6CDt08/wnvyfVLXLojf5UvNE1R9RFitLq1", - "ocWm2v0xY4jqAzB0fCai+PfNDEpQEYxLxHhissCrz7uJYKNS3FywuLciCoF5+qxoGlb7OpdNLXh3nYra", - "0BlfYUpMOhqzpaFhqprvDyGohXAQLQ2MzzTiWONTSy3MHh1nbm1Mq2NxHMrJMoq8Z0zSXf51fsA5rIHD", - "QbLwWUefg7JQL+oJ7hFKmZitwbu4x+ST6kx9kkqT928TngNiUK8HGsWBGgjHgU/DMK5VagzQhtW1S2oV", - "6fuTyjVUlhvB8Fw370KO8RqzCePpMC7VteZHFfsad9pyP3us/ue2L7RvbCWPe1Vkv3Wn1QJcD37GUc7J", - "vWK9YKZC1uFufKimHa/pxaujvtZFTgTK8J1bZa5vOKaJSQCHOZWYr0A2rvEyw07coBN7iZfO9pbVjV47", - "/KXVfMakJ3iXupwfYnfXsPgCTtAtRdFritZkrc64YQmZFfnG7r8dfBytWw7agxtQPsukzX2V0UzXSM4e", - "dfWgVU7m6p3ONAfbIVxnOfgiZMI3nki5Vr++aM2pUz9t3dOvJ8zob8zVCQeL2WTnR7rt95G0S4X7FyBU", - "k3Bo5ixJnGhItr9gOC0zpwHB0AA0aLv3YbpFZeGjecKW+tc7QpN+QTpLks9TiiziX45ecqV3vfVT5iKA", - "JeNF1rjShS5Z2dRfV9NNkAdigkDGHdVn+mqjMcyw3z6r66NeZ6ZmOSMxo3ul8ZoyqIpYXwmUshVDuttb", - "eyO/iNWm9wmn9R6tnOJoAt3Bpdmj+u+tIL/B007RNiyJlSx382WMfay+uya/wVGydz+ImOuz6Uzoxvnd", - "8QD9GMk1Z8Vq7c6z2lFwjzlhhUD/LkC7ltViMI6DgLug6tHfpmyr7h8epIaqL0owCNoaB7sj2aJ+3Zww", - "Oo30u1U1sm0S1Z2WOWnNcs02+s5iZJv1u2sXzU5JhG+Qh4asLkEtB92jJWQbIUUuMfG7LCyYXHeNrjbg", - "wWPXbhR8GietFTe/gBOc6Q3XWBaDrPMzHq9JZZ6bZeFdpRleBucG2r4KZohZ8wWUwDludJ6k39gWHV6j", - "j/IGWPVxmOgjT8ttou+bMVSN/TR2pX3GZ+P+tTWrGir1nG9cH1fD6W4W675LZ0nycZhcjj6azQ7CF8Fo", - "2zx2eOKB8cRaB6v9XO2+oRor2wdtVJXVsfIHKhy+hC3QsqtioLU89kgysF+0ueW14dxh+gXNsLodVghz", - "BeaHMMLa6LiGZwKQbQEWwsM+GoaF3wZxTxS84F8YkdoLA61DGxW9TgvbYXzc8qiY/gUsD7cYBgQCKWz8", - "BqvuprWy7N7vYxhaJuOjfbXvn8bz7OAo38fbhCo+1bXY7NH8cZthfjfQordMHGDTG7KNtOqrBoxfvGXv", - "r6LOPaWnlaHzOxJZ+h7N1Cam4yDRdQVz6o7uWKANpKn6t9qp+jofBhyXhj1jDI2hjB2yJNX4n6sOrXcA", - "62GvbTbdyZ2oQx/vcUqsIIW4PPKIGGb0KOV9yEHRh/AFK+9ZeaPAgI04eK1y8OxYbrsfgffe+KPPjp/x", - "pl07ObpujB2njps1lC2TbRFa2RBXqQqTY6EUCcnKBsIcUsACTJNIpHaIalswXZg55BwEUHPvo/vuO33Z", - "fJYRfW3MuiOu9U+L8kdvrKhslA3mFYEMxFA7xWZZQdkj1FQVmG6toQOaov/3NzdvUNm80jXdJ6K81NtG", - "BBeg21lm6owFiUs8fz/DOXmP5jTHtn8GpmUpgUCskIIklnVEoIVinH5V51UtdAXqgzKkpU28WnJNYp1B", - "VXb3IALxglJluhFFCEwTnDIKKGOJLTDULaIjhU3kVVK023nS6ULZgCB0OI/ESMhiuTypDlmaqO2Tm+5w", - "VNVNqJmGuzd5oEwvoQCseqElB8EKHkPt00KuA1++FcBd7KL2uutEFQg91Fww/kell6D90Y1r1ezn1bdP", - "oe0P/66DzJ7vwJ2h7W7QERqptLrrIeqpd4euViyBIUkKqNCxTxO0Smx/nxqBTAuaDorq/E51mvNSBMvr", - "vr2ZexH4p3dP/xcAAP//M7cdZDbSAAA=", + "H4sIAAAAAAAC/+x9a3PbOJboX8HV3qre3ZLtJDM9u+WqW3XdyUyPpx9J2cnOh1bKgUhIQpsE2ABoWZ3y", + "f9/CwYMgCVIURefhni/djkgeHOAAB+d9Ps4SnhecEabk7PzjrMAC50QRAf+6SBJeMvV3zNKMvNGP9K8p", + "kYmghaKczc7dO2gDL53O5jNyj/MiI7PzmeSl2iQZ3srZfEb12wVWm9l8xnCun2Pz7Y35djafCfJbSQVJ", + "Z+dKlGQ+k8mG5FgP+n8FWc3OZ/92VuF7Zp7Ksxqas4eH+exCSqLe6LHa+OpH6PLVaRwlmvaioXYFTEwJ", + "ytYw1EusyJqL3eWrjgV6x+hvJUGJfa97aPfGzR4c+pbiMiVM0RUlwiCXlVIRcZ2V65cbmqV7UDRvI/16", + "F47mlRuZleubRIN8BFQnxXIy/HiWkUSjspfS/s0eWvt3pqQ2Z4ow9SNh69jO/46nO5SYd1AGLyHK0HKn", + "iPRobghOiagQtTBPLNABZ4OV+dIidJlwdk1/J21c9BMk6e9m5IpjfPv8xf23z190nM2Esxv9US8ahJX5", + "7PyXANSfXtz/Sf//+X8/u3/+38/0Xy+e3T9/AX/95b/un//lv/Rf3764f/7ti9n7eeSUXyqST7I1qSL5", + "pPvy9UWpNm8Ev6Oabi3M3m4Iov4LtOICYYbgoxeosJ8hWSYbhCVazNSWKkXEYlani/05PieOS7W5ccAO", + "5J9vuFT7TlTBZQ/L1k8nPEVvN4Lg9CcsbjuQMi+g0uCGWYoKInKsgQZL3YGsgo9vcixuRyNcYTh70Bhr", + "KESq73hKSXhvXxN1cYcVhm1hD77+ExdFRhOsp3PGE0XUiVSCmKlWGKy4yLGanc+WlGGxm7WPBdy0Zqh3", + "RYoV6RnnV6nX7uNhN/pPpcLLjLwRvJBuvDSn7JooRdlaTj1qCDs2thYd3hUZx+ljrei8eQBgNITRimrh", + "SiOhjzuWcstFOt3MASgVdqJOpnkpyJTr60UlRhXFWbi07tHEFHVgI8Ssj/haWO457UQ9N/iRSuUGNpfE", + "1GtroMaW1jyZemUN1NjCetFm6ilWElhklv7h1BP1gCNz1WLBxLPUICPz0z9PPDMNMjKnmkDxEmfZEie3", + "kw0K0D1UM+KbDWfkylxiL3k63QybgMNpwrPrcpnTRxizglsbkks18W4B6amxW5p3iBkSYSNGbanaUIYw", + "MpII3CkayhXBibpI00lRA6CdiF2k+mYT+h2tLClucfQ4TbzhNcjmhj98sYz0NTEdDdDIuTcPJl4IK0C2", + "z/4/yVKfT/YTviVa2hFmVaZa/3KZ0eQHouUKuBlxFhk3ePjYA4PsLAvOZE1uDhmgvrhf/zC1YKtH+Imo", + "DU+jm/D1D7NKtP6+Q4qnOV6Ts4KtjxYym8NNP9+9o1op7FMO3FYkphw+hN7JbCwmWq2ILft/nv3n0bTV", + "+j8jW/Tu6kfEV1r3L0GlIGmgUlR6zZRLoKGORum4I1gIXmjmZY61s0zIQWpQMOrMaddGR/8lgFRZifjy", + "V5L0bbRSba7LJCFSTrm6FdSOoefWlgezvibq5CXnt5TUh4ip9N/h1MpMERsiTpE1N8xaiuKE03OAu5fV", + "vTExgw7B7h98cr4xYN5G8bpIU7DoTzm2gRyViqxhEyz+CKcpSU/RFVGlYBIVWBCmnPHztI6kVjI+MY7W", + "wm2wnDU17k+MDIxZQ2PaC9YC/SdVG73Usg8ZyswFooVtzFK3UiFyR/NauwvkQLyjXNbDGMJk3eQyKmsz", + "uSI5vyOf7YwIGH7QKTGYfkEHZXquth+ZEsa0aHiTy0WaaqVtSlQ87Cg2lesusjoNw9ZnwSrkJ/7niVmK", + "h9vPVSqsehmLf+143uJByeFziHOYANIgJlPNteIz/jdzgL/EjTr9SR6KVXievyfqkq34hGhocN0i0iVT", + "RDCcXRNxR8RfheDTmfYv3lwagJHR3bjIDIzsi6GZeMo1UCSPYqFIXuMT+odpOYSGqHnDG7jTZCcWfXxB", + "v/DJpA032HGiBszJn//KIv+piBqeqZ+5+hsvWdpW0X7mCq3gUc3kPCGSGminTcN6x8F8anchkkZRXZVZ", + "tmsZnCdEDEDGkNLjVYbmilPq368JFslm4uUxQK+ILDO1d5ksXePLNPkWG0y9brQEX9GMTMtTjI3Wgu7m", + "7aH1fcLRDdieFQkZqvnpe6I+yfCkzkaXvFTeIQFclSoJBJMBckdzVgNfDkM8ylodhCGcVQMAW2CW2ZmF", + "k5n8COyldshp3zFcqg0XVJI0FqFkn/5OgOE6T8b3RHkHypTyl3dgWBPd68JIsRPbAN00nPPUDzvhXNwY", + "oXcG4DzKnB5cdJXx9Dgxrh0fjIJ/W/s00a8iypKsTClbI4w2ZY6ZvlFSvMwIyomUeG2CwTDbLZggGfDO", + "nCicYoXRSvAcqQ1x1lPzqpQ8oYbJEnFHEyJPF2w2b5xFEsfUsAYrcsI7c8S4gt8YWNO5QISlJ6UkAqVU", + "FhnenbadBvOZRT+2GDDRk9ZEx4xhVgL2TJpSPYJxdbqJmhC4BgJsh6q3q+V066s4LCrMPhjWcZr5TJbr", + "NZEqdnQvkH+IrGSgZ6Ph6dlEZtHgcIYu7yOjOu+TnmuWvV7Nzn/Zp1flOWfBajzMB/m3qu/k7KEHk8rh", + "OBynWmDpQHyqcQ7BCe6P848QHCsPdqFqkHYMLATeRYcw6LSuOU33u8jGfytKgugKNoPNUkBUolLq4682", + "VCLN9vV+3PA02ClLzjOCWWur2HEGrUYMzVJtbvLq6UHrE72daxB70Ao3WButNKcsYLd+9vPZkvIIH57P", + "bKrHYRkd8xnwOSLVfoEEr818XcTtoIF+1q82l8hnpQCguZ3t+2pt/u7n0mbMNjr4/9u8GHuR2K1Uj62+", + "DrNk6gs2n92frPlJaxVj8bEt6nxmEly+kmOp0LUZf7aw2svtzijfMiKku4iQHry+2N9hwfByh34ghJHY", + "PdUdBBxhHglh6ibhGS9FdKlriEaeK6oMJdoXTXsN2iEFraW4VlzsUsIQZVLhLKtML7B5qVTC/CQtnNOW", + "sPGok6rpB/BaHdy8MXyUMUFcQYsYG0LXGxXJQ5nPaDooVuHyFcgpNCc3BkRkbqXIor9vaWpSbtpJMOGc", + "IUtBwwjHcV/P3Rw6Z335KibFWFbTyPKAS0oQyUuRNM5AknybsfSFfC7//JdvX+BUld8+m82r6JJ7QHMg", + "J9J4HXZ/m7iQyJ0NYShXP8ZPeBUtgiGDz8eMWBGwyLDSM4gKnxdKEalg67/k7I7sMEvIG0FWRBCWRHjK", + "RqlCnp+dbbfb0+2fTrlYn729OtuSpb432cmLs38jrMxPcAX3JAHAIL67FKSUCk0+/YMiotAqJGSF+N8Z", + "ZySScOSi/Klo7/OKzKAaeKLylLLY1BW/Jaz+auHSB/YJuMFYDlB0bzYykOoIZ5Tdxkm62RVE6MeahkLr", + "E2KfBD6fZXzNb+wxbIPUTzU0dwE4cC5wJwqSdV4rDe1Hv6g34V6IRW8+lszK9VBYHQFIlVTi12NuVnof", + "gQ47q3UVoH1kgyikyE7dfwnQtBNhvfWMXeGv94owSTmTLzNKmLpkRankYYrk/gOd0kSlZHWCa2MTP3YC", + "Y1MYe8Fm/VhzcaEUTja5tZKM4S4NZLjAHmSNyzjON5vPEsGlPPE/dHEWD/HKRr+OQbGGmgujjVgvAh75", + "2ixV7AKtQXtl7QSttwwN9ON/XL/+OfqKpGuGVSni97cSmMmCC7N9/Blov9fY6JodVeJ+/55uIPl+3065", + "Jj6sgCoiKB5Djcju5UI6yImFHCNP96bdxxlin1VrcUUk3B8/kF1cRRT1F/odO/7VKwPdDaYJ8z9E0JU9", + "r/sgvWu8XwMX0ZFjc6yjHqOvD+N7PAOQD70MLUADv7nwbDNuoIm81w6q5VK9dEYuC0GriOuI2Fu92zfa", + "WFPDEapKTtReM/VPznA5UJl10zHa7HwGyd4Dv7nW7+pvuBiyrlYEsOnkdUXKroqF5awXdsp9ZGgkLQ4V", + "FcIs6jb/jKZ+/qGJHCdlBw2t6amHao5WjfgI89QJZEPoWEUgN6nYvOYq2H2I7TGh/LEo3rlKccvWha8a", + "840EjehkhRPK1t6u1Zq5g3cVqraf8gbq2wrXdsl6Jvnu6scTiVdGR+qdoQbmNn0TYGbdyb7mjl4vU+Pk", + "kCPguHGLmdlw1kdcWhux3ljZ1sK5wG6JMFoLXhZ61jBHMPpxtSHCvSVP0aUCPyORCOsX0ILhpVQicH4B", + "EL3DpBJlosXoFIHDzVDTwEjA9VkIIkEVURvK1tLXEFkKzFI5Rzlm5QoDDCHnyLjJ5RwZ4wf8SVRyiuxc", + "5YJpuEuCvFkmRbQKb4QIB5iV2pAdwpnkaIPviP4nFYhv/aunce0ssqZR7TzHlKGKS4HRqQrbborPDVY0", + "gKivgi8e5iaNzxk09trN3l39OJhhmeEcvwLL+N4gHBN+U3GPh+Z893xdbfBhDLIq+nSQcGMm876byq/2", + "3BCxcgmty+mroe2XR6Ie0kCI42DWaQIi27yPAZtDS5JxtganrI0EYEnGwUvrjuyCNQbfd2sY/mlTvzVM", + "4Cv38Kw2XsUW0Cu6giOjFgwiPTBDbii0JAkuJUFbglIOERqMGLu1iSghxgZYyw9ZsDDoizKtbiKCk42Z", + "tqQsIYiqbyTCmSA43SF8h2mmJS3D/oZddAFFuu+5g9QAn+rRCa4pELaiV8k5qrYpwkLfCEWGE3KCs8w4", + "swSBdcyJWJMUSIXIPZWKsnUsgOZfBzlykLvOpxNFu3hmlxRXE91AmDCOqWznXFM7fW6cS0rGpbtmOttw", + "GctvvElS0g4/QdEwCwNkHsSZt3mZFjpWZZZ1CR1h4FmWBeJdjndLYvLNFsyNgP49JQVh8DpnaLvByjLG", + "tODUhLEknK3oGoQ7LtBvJRHUMKSU/8dC8x3rjTGxbpqbZlVxO84QRneUbM1Ja882yvurvJFHlJqrBK19", + "gnOQu1STnW3wKcQRpGi5Q9h4orTYi7OMb40eJpHiC5aUAqtQANU3CNDOCa0+6k9SRU5RhaAEIZqzbLdg", + "+mUtcwrOFcrIHcmssPvvFpv/MBwOHOaG8vqIaRyQ9Z51ibzRBYmcXS9yu2u0WqB9zLTTm9Z6MFICHWIo", + "6ZEH40Wj9sl6Q2e1H7k9SB0kDB1xIiAFqXYqWnj0219BfRujP8iNNWa2oi/1A3RHhLSRtnrjmS3/jURL", + "nu4QiF1wlUiCQC0jmvPI2n4PfD8DrsGweGIQq9JmyfCojlY9jOLvJMs42nKRpf9nr+PWrp8Xll30i1md", + "/ZvkMCGsvr9islg9P/JwwP1A+41+489azyKNERkmumBaEscIIvVIDweJDB7oHHXd4/6VBZM8J9sNEQSZ", + "/+54CRcTXq24AIlAbvjWpmUQK3p4rcjBOUwQaKx522ZtMm0uVNexzIkNpDeCJNpiWaXnBGFMKVbkRL8e", + "YxUpycjBo0i+Uif2y+FD7Q8/q/tOciqTCL8US6oEFjtE7pXAxionFRdOAQqxjYbC26SWw6bsM2GGzTYW", + "71YRNMQhvjlAbPqBmrxGH+DApf7W8OBoUEPw4SEHsBotxs26Um1GeOdlothJ4gHaHBBuAJ74GJOI6lq4", + "5JgRNc5aKUINr6wHHaPFZS3O7IuKOYTs70hpIkkTZCYVSZnTOzsaHvsYIbCcLTkWWge7kQqrcu9efO0/", + "uDbvTxtHG8MoSvTHFUfbQmiXXY+CfwJ7nmdQ1GKgSTmiLCX3cK2xHbqlLNXXX+WzWDCTdOWi/0pRcGnv", + "SJFs6B3O5khCju4cpTwpc8JMiNJcX6lpmSjrnljA7WzMUJLmNMNCX4tGQdM3IRE5wIUBc56SDC1LZd4n", + "OYbwkUyreakzEeq7Vk8TJTwnoMVZ/E4XbMEuV3ALb/V1rDgIvn7bKo5EyeCaz/OSUWUCHLU6nhKO1jgn", + "+ocFs+dubm/shJdZipbErB8EW1rvDcKJKrEzKnh1VUNasO2GJhun9uYkXxrF1y6cW90cYYnQlmSZ/iPQ", + "JDdQAWDBKs+N9Uf1umkimsh+H40ta69ncZSLRg/+qUx/eqwv2jnjeh5M5Jlprm2Mb7aKHx/jk/lcxPzC", + "aNJFi4FuENALKs+DdVnISido3bRUyQWruzOQ4vwU/c0q8iCuXry5lEhtsEJbzBRwQRNojLBHYcEMEvBa", + "jneahRVYwLOKnXr/9nDHR6uASVv8a1XH/uJcFU9+f0e3bad7wn/6WL6J5qb5hHLSND6Nh7a8deUEAenu", + "z0qZbBzhukMSuEB6it5JsJMvmB3RnFXOsp05197sALBxxtnajECVjIHukAp+Gpc97uXHKg/fioS9mnK9", + "SH2kDlka34Jash4gsZvX5gZOjD23tIHWln5FBL3TsrCW2KwpACst8LGUJlgRaTw/UplsfZhzpQNoXpsQ", + "KResUy3SIjg1QUEmYkd/tqJCKlD9kSSqLJBUpLCM12nrdqbyBl6+sZmZlYFI3riwrPC3nAvi3pXhAwPF", + "mgD0Ds+IiudMxav9R+XHQr+KTJKer8hQ4F3GjZG3L+WqDS0lUpMWPEOQ1lM5ZsxBCkbraZDXziLS393Y", + "VML98wC5PiHUxEQhzoyRBulthoyee0C6V23w2CaNNjqIYglvIgmvGmw6l7rjaLXK93UcHCh31evG0Pfe", + "sBRF5wce7/lY8nQ3pBqTNUSNiVyFmlZyUF0sNx8toexuFD/MKCk4hyZbh390uFNmgPwCoktjVzgUw3Et", + "EeaV/8Wu2Nxthe5t5EvctHd05ZwCq3u0VwQCo+quIJqTEgqqr2bTYI3XSjpm1qwxR22XPdhe9d2alvBB", + "YmvjnKJrgGAcyEuyYN4msjQGsAyDWULjJlCOxW0axEYaNdzEcoJs6r5eMM2BkWGw94B3FdJ5nWFFTn+V", + "iKRU6QvBWky6/HCtriTt2gSf4miM2ecj9x7Mp2sr1YSXkRJjJ+z+EhCPv8wHLFh0Ah7zYStTW899cnTz", + "OoiFgjCyjZ5ffbJNVTV0YV7QCihsKoj9Y8aYBU8oM4KU/XK5Q7IgiVUq9IMPbjN+cFarneEPgQHdCGkL", + "Frx7h7OSoLyEIMIalhBTAqKGYTZxqbnRgqfFyq5sRUTDCpJSaIE/26Ff9YiSalZgGZYEoyZEXutloLlW", + "1gnSfEFES1bl/Fc60IfbrpcYkbjriWZVbQdRfTJI8w+qH+7Lb/FiqxkhegKbt35E98wpoznO6jE29Vow", + "g3NixpZuOfDePrZyDlzCHeVz4qtYm/7h6t0/rl//7HwEoIDqy5Hca91WgosgqCHm1UC8YN7Vab7VZ1Kr", + "PbJe38wk9CI4D95RIJ113hrclbvA7eUKSm7lwAi1Z8WRxIrK1c45GyAiWIL9/29coMp8HzgDliXNbPW5", + "Jee3MI8llmRuvPZg4tf4ABN50xFKqIc2rMl4yuSmodm7Kz/FiiC+WjAoJUvZeo42BKe/lVgoyOeQ9Hdi", + "MzhsUgZzw6P66IBQEDqAVQwdmFMME0EygiUBjOYLZpUdzZ3xmngvTZT9Rdo+jXDe0hVOyElxW/lvD0uj", + "7shi91UNAq7XmkK0hsJ8JvD2suNJkNE/OH/blwHwPPHjEMe+wSIY0379fhgtmuUeDyINqae9G7fvLdlV", + "RHISs/Wy91cm2LtcewrINCsY+Jz+g+jQrgSgd8sGZxlh67jJidyDJa5a1QOuwjZJnDmZRwP4q1oYB8yq", + "u37Hw3xWlEs7PvRaPgp3gEDAKBrBXRRjAiiKvzJFlcmFpTnhZTQr21QhGAH/nSTCjdBUZouZBRvugCi9", + "I8s48AQG5D6i5ETk7KUecOTYdfC0jtIczqy4zEztJFPvVIsVqwSWaKlXCJvHm91S0HiIUHNDOD53IMne", + "6s9aIRimjFdHMZv+vTrtwhcecIzfZeuoDP0IS6GHGrgWx0dX9axHPdIquiYZ334S7tnPx0XRcaHv5TvN", + "6idV8TGZ8FLgNUlh1vquEqTWJv/9PotwhfNQYjqOOTEZCwJgh3OTg+L1hx/ct/aojK3nFJmbHrZezwne", + "ObmtBeYFxrXee2Taddf7q3PlbY21TofsUZQBAdOlUwQDddPJtQ44zi07rIRqLUZ5sgKrOe5gDp+j+m1U", + "hw9DeSuk3ketk6YZR8uU02UZOtRK8dA15L64FuGNXhCuCla1DZZog607tSC8yMjgahG26Uib4XcUrTqC", + "e7iyU7dkJyqIjZKTI7j+fPaogRNvcRS2wmtkQgwTzIzDtDBnWCLw0ptUvDuKkd9rMY9hZ5TuY5i93uJ1", + "93FhXRzKncuebanweniFEr2ikR0XVF7eMxK6fDV8tP7STm5Foo4yV+US61Hjm8NE9Q/m2ub90M8aq0z2", + "GAZhn7JlHIsmc2s+KyhjcMC8i1EvsH4AeMxntXAHcD62t8h7vxKT+82SoBbdAUkoB7qBhoW5mykGIe56", + "pQ4qJ+6D4vcP8xZeHe/Tc/S2HuSAjD0R9EFDnKE7sL2j22es8o/HGKnLmbx8Zfy7hTV1A9OWRCuFyqUz", + "p1hu0P8ztSNsFkeOxe3pgoHt20Z7u2xxaaJKZMEZBI7fYQEMf8Vt2DsOR28bsNf0jgQ+NR9bdvkKfYil", + "hHxwxuQFA+Q/KF6cPH92kvM7SuSJAfNhXoUsbWmWoZKlREilP11yOwJgeL5g0WFOomBh7DhaC4Ygti2S", + "8gL59ZUTrj/lJTpwIw/mRN/a9J6kJ7dkiZcnCZbkxKfEDEuRsRtmaufwv3jJMe7u5kGfUlP5pIFNQ7dB", + "uxqdqes3tovr4VvJXs4tpvnPDQH3feC117oAvG28VFT68nGx/i7mer/xjumI6FM5qiABBpiUAVxlk+v/", + "v2bZzjk42yaeERFej5dx34HuURn49tj2SqtBoyx/hVSLOLyM8+Ol+x8tZRwiVd642IS2aGmPiA9vm+/p", + "dRyJiLHnoYpX8DkfObc06W9KuCzVgqWcSNuOLChyBSchiGFxsXLvJFmVWSNlPcNiTRbMV1XxxVmEzSST", + "VJXWGQ85dTteopSzb1yFLZclr7mBrQNWuzU6ZSkbXIcgHigVeKVMfLXWVzMbXrtlRKAc3xKJkg1ma5PK", + "5+uFMXWKXts8uB3E12xwUexc8Pvc/K7HsY745sZzCr0e3fh4wF0f19/DW6p/e+NRmzvaluMCbckS4TQV", + "RMpQiDHtCNpAempvA/AVLjP9fWi2GGsrKaHSZTXYxAaTvc0Lj88SbziwHy1NvN12cXieuGb5JCkFVbtr", + "PYKVLAXfWo8o1VNPTIdGZ2GZSSu9n0gipckbdJy6oHqgh/nMLcx+IH4JO6E9gA3VJI1DtSVjmLSA6i2h", + "Wi0nvaoBV1CGLt5cmnBbF49TJeOmAtQd13/BWMPMmfTozuYzewHPzmfPIfmzIAwXdHY++9Pps9PnmrZY", + "bWAhz+yzU9dZc01UVyIa5O0SRgRWXNiCGBJh9CHHxS9m474HO9oKJ+TjwwfT3s6EO0mioKLVh2Y3zw+n", + "p6dIcnT5TW6iAk0HvCDIWC8F47YYmN6S8PFlOjuffU/UdUGSIEIEJvXi2bNGD1EN6Axg7uniGesJHGzB", + "2fkv7+czWeY51sKpRgCW5XVBmCbbn06f2XgjO0et1P3j+vXPp+5+Pf/FlN94r8Ge3T0/8ykpXYvvxgjv", + "Q5dkVEVUBsEh0G3Sh/7VV8wa5L8nqmPRYkfbv3dWfW6aJf/52fP9H9X628JHf97/kW8/DiSxfHvfR7G+", + "/A8P1cr7tX7/AGcg2UT67UIBkclX3IC1TJ9I9V2Pbly9Qqs1twAejiCbb3P8VVOucW7OJMlWZxrPk6B/", + "ZfQkXRElKLkLE4DrvXh8nyQXXYlWGV67lDfNl8CdsGCc2Wxc03Zz8O6I8LCgm2atg9IRdG7CchQfAOE7", + "nNpwiUnIV+ebg4l5hxUWztIeO6IZh9bkyLzpl/+wI3lN1IUZSTODKl6mw1ZSveIK+/xI2FptQMUZe6or", + "HDoOdqxF/dM5ux/tXzfGD/wQkL7zLmyT3d64w+69kSSvOdMhusrSffwVWhH+KyHo4NPs8gv6r1jG2Qlh", + "d75YbL1xqK3CUy+j1CBq2LD0iAs2AmbcNdsGNJr1jtoS0x1Z24nYEdTbfvcw5NTlfSOMcpJSjFbURDo0", + "KAfVIeCrz8J8g+HHUboCcARLno5cNtO0Tq+zjzR96GSlr/iW+WsUGp4ud1Az4fJVB72M0nAg29QfvsGe", + "UKMW+mtTNzr4ZJNIpWnoe6yoelr5KmVZQHyzFlzJFi3YFu/AaBgKRnMThGSz71yrVngNylLAMXbWJ5Ow", + "tGC+uLciWSYh34eaSmNQwUt/luACL2lGfaUawvAyI2lU6J1E2v3SxVxN4Bq5zzK+tqG2HVTP+R1BxhBl", + "q6VZzmUaTug1P+1fTTPCQGFyPtsQnNoo8WuiTl4aG1i/keQzrXLPunL470f43407GQ9nSVhhJXpzXdM1", + "A3ccZEy6ukm+27vVAn3dDbjh7Ilp0+F1SAhf3eVQlvm63hN3zP0WR+Rh7CGzDXifAg9ubx1HzjNJ18yK", + "rY+/VUz7bfP02gw8Ro4JoPyLvPvJWxbd5L0iawopoxgy9qcha1l8MWT9gm9FqATUc/AUFqpp3wGbbMa3", + "jkC1EkhQ+cCYFIQJ4JKEpQuGGzWLXPkkwynTerUjI9pAbQTIPV4SBAVNFTe1GGx5BvikEo84Ap/gDgBb", + "SHrP3OGMesNyjzmwWWNqzP5pwfij7KGWPcl4LiN76qWt89UqnxXdY8udLS6lXL0Nt48WzGwkV1HH7hB4", + "R/OMb6SB3knqqr7VdCapMdslwOMPsFucRxc0ZRPKFOc9tX1Sec6R+Q4cfCxFsiYadBohnVL1E74lFw7A", + "mAMeB/RHFQA+Bq78X0yq0GDKRzlGVDerbiG3+sEmsOWhm0Jh9xb4nqhwB3wmW3QMm6cpBnqy5/iWDDju", + "nsYCxEJrm17ubJk0KJKixcSKJfQf96BAyJHnPYD0JBj1uNOryXjU2a3R1Rmtl7vQ3IJD6kbubwfLSVoh", + "iT/zgW6h9GXfyfUu8t2ev8oWmmWo+ghxVvXAa5Gp1sB+zKKGAMw6PtKihA3vBwWoSC4U4iI1UeDV592L", + "YL1S+pMxjCgG5uGrWtM424dYNn3gXT93faFzscaMmnA0blND46tqvj9mQS2Eo9bSwPhKPY41OrXYwtlH", + "R5kb69PqOBzHUtJ7kQ/0SdrPL18doYc1cDhqL3zV3ufoXgjq0UcvCOiEDfeC69bQJnJQq37U4lbfu5X9", + "MgTeoPnvfhZnK+PpcwFdafWpqFr+2g46rtev4mvIY4rJP3Y5jmB+NQAPR5Ckzvo+696tSNHYuWcf7V9Q", + "OPphj6TjyGSd8u+ufoRk285NPcY5H/TbPkborDB4Arpj/Sj1SmBVd/4uooy9TeJ0GXe6jrpNQhBfZezh", + "4OPY8fsNND9/MHsAGkN0Oe0Dzip4Doe20d8Essdx4rs2KF6Ybtw9zNUAd63nj99I80O+eannPgFnsJPQ", + "0L72TTSPuxOuQ579jae8JXQVn5p4QkapfZGmXzmp9QyeAp33MAuQl84+6v9Vt/k+BmHbHwF72H93mK+g", + "X+an2AuuudVkx10DfKKn/SJNPTUVH0DLizT9Gglp0X4qZ7leFmKPElm9bDMSIdebZspkjtuU2QjF6xUl", + "Rq1+DcQXpmmGuf4DlE3/uqlzD0H+zgrjC1aQ4dlSQYP88WpnE8bDcVT6gpTPGnXa+/7sY/WPm77gcKuD", + "VtSrYsPRy+Bo2CoGtic2F6gQ9E6TXnJTY8nhbqJwTBci04II4oZtkBWVKMe37pS5dmlaXqa2ur/CYk1U", + "iBGVdti5G3QOJRNSBPnCyv5judsXcVPNZ5QO7b+u2/7Gb6cnokc3GcU+VbqibJ1ww1L6quUbq3N30HE0", + "bzlK725A+Tpv4AOZkROqof4MHahzQ3FVJ1F7cCYAMNhSrsNRuLUWzLGfNu/p5xNm9DemY+TR22y/SAfd", + "zibiLhXuT2BT9cnnZmsY8fywjeG4zIJFNgYAAND27sOs6nSTmid8Bb/eUpb2b6SLNP06d5FF/OnwJVe8", + "pbcCh+l/uOKizBudbNmK+3ZCUI9ljgIQQQuhVv2SSz3wGGLYbx/VeV6vVKJneUYTzg5KBDWFNKrF+kai", + "jK85gmLk7Yv8MtGX3hecGDpZQv5kG7qDSmcf9X9vJP2dPOzd2oYkid7L3XQZIx/r767p72SS/M9Ps81d", + "sb9+C4FxmR5kG7hUJB9tFXAff1n2ALNYAywBzlgmXD94fUNTkkDJOKlEmahSkNS2Gres1BnZKFswjO5o", + "Sjha45zMIcxaKJqYknNJxtUGWshh3/AOKutJxQXpZL/QBX+0GSH4+mEsQb8c04EjZHgImgbuHlMBkGmv", + "r1pPeRQTmcCmacd+Aqp1cOb2KNX6zTgVRmrJMUKMODbH6MbV91+l9Nk4Z2AIPZPQnLY7fBkeI7URvFxv", + "nPEUbp47LCgvJfqtJBAJqyUvcxNF7p+qD26b8K0ypeReAVRoRmwQtCVZrPpja5BCo5bZ+QzerYon2pr2", + "3Vnk89YsN3yLOMt2yDbEtSUGrVpGZWj9iQ3pC9lWgx7QHqeNkF4uOQ+Lwi652nSNrrW9wWNbUfUHylI5", + "exjH0CpqPgGeZlpZNI7FIFPQhUg2tLIFmWMh+UqdmC/ix+CVgXYo/xuiQz+Bil2OGp03zBtbUTioS4yR", + "XvnMGEfiiz7y0mkv+qEJjtXYD2NP2ld85fSfrbOq/nuPMc31tDKU7iYxlIm/SNPPQ2Q/+mgyOwhPgtC2", + "19XwPCkjy1tvnv1c376xklC2bcOoolBTpTtVODyFK9CSqyKglTwOyImyX7SpFXQN2iP6RcWwuhxWShPr", + "8imEsDY6rj+DJMh2LIjhYR8NwyLs2nIgCkGuQhyR2gsDpUObxKE1LdNyY9zxqIj+BI6HOwwDbE2MbMN+", + "ULYTRBCFGbRdiR2T8Tah2vcP42l2tF3o811CFZ3qXOzso/njJsfidqBEb4k4QKY3yzZSqq/6xTx5yT48", + "RZ13Sk/nFWeZpco7uszU5qZBCoUyKAvmVHcs0ZZkGRhzq447PY1aImZaQ54xgsZQwg45knr8r5WH1hsW", + "9JDX9sbrpM6sgx8foCVWkGJUHqkixgk9inkfoyiGEJ4w8z7zDVAHXMRglbE7qZv60AbQXbufgfbB+KN1", + "x6/40q5pjq55TIfW8XZDfIc3WzPL9+/SrML4HjQjobnvdyZIRrAkpqcN0jdEdS2YpnHeMWgYk/3ue6qg", + "/Q2FFtqbjiCK/7Eof/Y+MFpG2WJRLZCBGOv+0qyC4lsamSIoprlUTEHT6//3t2/fIN9rx/UIpRKlPClz", + "wpQNP1kS6L6Tax2LpK5OxoczXNAPaMEKbMv9YuYrn0jESyVpaklHJVpqwsGrEMS7hIJ591qQVjbKdyVg", + "iSFc1xcjphKJkjFIL9YLgVmKM84Iynlq66FBR7uZxmYWFH5pdx9iJ0stAxIJsSM0QVKVq9VppWTBorY1", + "NyjIXpV50TONF5sPQJnS5xFY9bpwtYbkge4b+fKdJML5Lmqvu8L5EddDzQQTfuStBO2P3rrOcmEZkLYW", + "2v7wbxDRFNgOnA5tb4MO10jF1V3Lo4C9O3SBsUSGpBlBJQTaGKdVasuR1xbIVMzuWFFIJtDaXBCP7nph", + "hjMPwr0iVBVLqgQWO+PB9gnxBdYCi/F3peQe9I8qSCHwfblRXLrJ3iEOhWwchg/vH/43AAD//7nr4uJK", + "CwEA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/tools.go b/tools.go index d427c3cf4..c984695f2 100644 --- a/tools.go +++ b/tools.go @@ -7,5 +7,6 @@ import ( _ "entgo.io/ent" _ "github.com/99designs/gqlgen/codegen" _ "github.com/Southclaws/enumerator" + _ "github.com/a8m/enter" _ "github.com/deepmap/oapi-codegen/pkg/runtime" ) diff --git a/web/src/api/openapi/clusters.ts b/web/src/api/openapi/clusters.ts new file mode 100644 index 000000000..93f2042d5 --- /dev/null +++ b/web/src/api/openapi/clusters.ts @@ -0,0 +1,204 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import useSwr from "swr"; +import type { Key, SWRConfiguration } from "swr"; + +import { fetcher } from "../client"; + +import type { + ClusterAddChildOKResponse, + ClusterAddItemOKResponse, + ClusterCreateBody, + ClusterCreateOKResponse, + ClusterGetOKResponse, + ClusterListOKResponse, + ClusterRemoveChildOKResponse, + ClusterRemoveItemOKResponse, + ClusterUpdateBody, + ClusterUpdateOKResponse, + InternalServerErrorResponse, + NotFoundResponse, + UnauthorisedResponse, +} from "./schemas"; + +type AwaitedInput = PromiseLike | T; + +type Awaited = O extends AwaitedInput ? T : never; + +/** + * Create a cluster for grouping items and other clusters together. + + */ +export const clusterCreate = (clusterCreateBody: ClusterCreateBody) => { + return fetcher({ + url: `/v1/clusters`, + method: "post", + headers: { "Content-Type": "application/json" }, + data: clusterCreateBody, + }); +}; + +/** + * List all clusters. + */ +export const clusterList = () => { + return fetcher({ url: `/v1/clusters`, method: "get" }); +}; + +export const getClusterListKey = () => [`/v1/clusters`] as const; + +export type ClusterListQueryResult = NonNullable< + Awaited> +>; +export type ClusterListQueryError = + | NotFoundResponse + | InternalServerErrorResponse; + +export const useClusterList = < + TError = NotFoundResponse | InternalServerErrorResponse, +>(options?: { + swr?: SWRConfiguration>, TError> & { + swrKey?: Key; + enabled?: boolean; + }; +}) => { + const { swr: swrOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getClusterListKey() : null)); + const swrFn = () => clusterList(); + + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); + + return { + swrKey, + ...query, + }; +}; + +/** + * Get a cluster by its URL slug. + */ +export const clusterGet = (clusterSlug: string) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}`, + method: "get", + }); +}; + +export const getClusterGetKey = (clusterSlug: string) => + [`/v1/clusters/${clusterSlug}`] as const; + +export type ClusterGetQueryResult = NonNullable< + Awaited> +>; +export type ClusterGetQueryError = + | UnauthorisedResponse + | NotFoundResponse + | InternalServerErrorResponse; + +export const useClusterGet = < + TError = + | UnauthorisedResponse + | NotFoundResponse + | InternalServerErrorResponse, +>( + clusterSlug: string, + options?: { + swr?: SWRConfiguration>, TError> & { + swrKey?: Key; + enabled?: boolean; + }; + }, +) => { + const { swr: swrOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false && !!clusterSlug; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getClusterGetKey(clusterSlug) : null)); + const swrFn = () => clusterGet(clusterSlug); + + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); + + return { + swrKey, + ...query, + }; +}; + +/** + * Update a cluster. + */ +export const clusterUpdate = ( + clusterSlug: string, + clusterUpdateBody: ClusterUpdateBody, +) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}`, + method: "patch", + headers: { "Content-Type": "application/json" }, + data: clusterUpdateBody, + }); +}; + +/** + * Set a cluster's parent to the specified cluster + */ +export const clusterAddCluster = ( + clusterSlug: string, + clusterSlugChild: string, +) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}/clusters/${clusterSlugChild}`, + method: "put", + }); +}; + +/** + * Remove a cluster from its parent cluster and back to the top level. + + */ +export const clusterRemoveCluster = ( + clusterSlug: string, + clusterSlugChild: string, +) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}/clusters/${clusterSlugChild}`, + method: "delete", + }); +}; + +/** + * Add an item to a cluster. + */ +export const clusterAddItem = (clusterSlug: string, itemSlug: string) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}/items/${itemSlug}`, + method: "put", + }); +}; + +/** + * Remove an item from a cluster. + */ +export const clusterRemoveItem = (clusterSlug: string, itemSlug: string) => { + return fetcher({ + url: `/v1/clusters/${clusterSlug}/items/${itemSlug}`, + method: "delete", + }); +}; diff --git a/web/src/api/openapi/items.ts b/web/src/api/openapi/items.ts new file mode 100644 index 000000000..7c1328fec --- /dev/null +++ b/web/src/api/openapi/items.ts @@ -0,0 +1,151 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import useSwr from "swr"; +import type { Key, SWRConfiguration } from "swr"; + +import { fetcher } from "../client"; + +import type { + InternalServerErrorResponse, + ItemCreateBody, + ItemCreateOKResponse, + ItemGetOKResponse, + ItemListOKResponse, + ItemUpdateBody, + ItemUpdateOKResponse, + NotFoundResponse, + UnauthorisedResponse, +} from "./schemas"; + +type AwaitedInput = PromiseLike | T; + +type Awaited = O extends AwaitedInput ? T : never; + +/** + * Create a item to represent a piece of structured data such as an item in +a video game, an article of clothing, a product in a store, etc. + + */ +export const itemCreate = (itemCreateBody: ItemCreateBody) => { + return fetcher({ + url: `/v1/items`, + method: "post", + headers: { "Content-Type": "application/json" }, + data: itemCreateBody, + }); +}; + +/** + * List all items using the filtering options. + */ +export const itemList = () => { + return fetcher({ url: `/v1/items`, method: "get" }); +}; + +export const getItemListKey = () => [`/v1/items`] as const; + +export type ItemListQueryResult = NonNullable< + Awaited> +>; +export type ItemListQueryError = NotFoundResponse | InternalServerErrorResponse; + +export const useItemList = < + TError = NotFoundResponse | InternalServerErrorResponse, +>(options?: { + swr?: SWRConfiguration>, TError> & { + swrKey?: Key; + enabled?: boolean; + }; +}) => { + const { swr: swrOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getItemListKey() : null)); + const swrFn = () => itemList(); + + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); + + return { + swrKey, + ...query, + }; +}; + +/** + * Get a item by its URL slug. + */ +export const itemGet = (itemSlug: string) => { + return fetcher({ + url: `/v1/items/${itemSlug}`, + method: "get", + }); +}; + +export const getItemGetKey = (itemSlug: string) => + [`/v1/items/${itemSlug}`] as const; + +export type ItemGetQueryResult = NonNullable< + Awaited> +>; +export type ItemGetQueryError = + | UnauthorisedResponse + | NotFoundResponse + | InternalServerErrorResponse; + +export const useItemGet = < + TError = + | UnauthorisedResponse + | NotFoundResponse + | InternalServerErrorResponse, +>( + itemSlug: string, + options?: { + swr?: SWRConfiguration>, TError> & { + swrKey?: Key; + enabled?: boolean; + }; + }, +) => { + const { swr: swrOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false && !!itemSlug; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getItemGetKey(itemSlug) : null)); + const swrFn = () => itemGet(itemSlug); + + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); + + return { + swrKey, + ...query, + }; +}; + +/** + * Update a item. + */ +export const itemUpdate = ( + itemSlug: string, + itemUpdateBody: ItemUpdateBody, +) => { + return fetcher({ + url: `/v1/items/${itemSlug}`, + method: "patch", + headers: { "Content-Type": "application/json" }, + data: itemUpdateBody, + }); +}; diff --git a/web/src/api/openapi/schemas/assetURL.ts b/web/src/api/openapi/schemas/assetURL.ts new file mode 100644 index 000000000..493d5d67c --- /dev/null +++ b/web/src/api/openapi/schemas/assetURL.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +/** + * The URL of an asset uploaded to the platform. + */ +export type AssetURL = string; diff --git a/web/src/api/openapi/schemas/cluster.ts b/web/src/api/openapi/schemas/cluster.ts new file mode 100644 index 000000000..f861e3f66 --- /dev/null +++ b/web/src/api/openapi/schemas/cluster.ts @@ -0,0 +1,18 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterCommonProps } from "./clusterCommonProps"; +import type { CommonProperties } from "./commonProperties"; + +/** + * A cluster is a group of items and other clusters. It serves as an +abstraction for grouping structured data objects. It can represent +things such as brands, manufacturers, authors, directors, etc. Clusters +can be referenced in content posts and they also have their own content. + + */ +export type Cluster = CommonProperties & ClusterCommonProps; diff --git a/web/src/api/openapi/schemas/clusterAddChildOKResponse.ts b/web/src/api/openapi/schemas/clusterAddChildOKResponse.ts new file mode 100644 index 000000000..2f6f791de --- /dev/null +++ b/web/src/api/openapi/schemas/clusterAddChildOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster child added. Returns parent cluster. + */ +export type ClusterAddChildOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterAddItemOKResponse.ts b/web/src/api/openapi/schemas/clusterAddItemOKResponse.ts new file mode 100644 index 000000000..6b8c2f894 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterAddItemOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster content added. + */ +export type ClusterAddItemOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterCommonProps.ts b/web/src/api/openapi/schemas/clusterCommonProps.ts new file mode 100644 index 000000000..de0149090 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterCommonProps.ts @@ -0,0 +1,25 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ClusterDescription } from "./clusterDescription"; +import type { ClusterName } from "./clusterName"; +import type { ProfileReference } from "./profileReference"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +/** + * The main properties of a cluster. + */ +export interface ClusterCommonProps { + name: ClusterName; + slug: Slug; + image_url?: AssetURL; + description: ClusterDescription; + owner: ProfileReference; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/clusterCreateBody.ts b/web/src/api/openapi/schemas/clusterCreateBody.ts new file mode 100644 index 000000000..17667626d --- /dev/null +++ b/web/src/api/openapi/schemas/clusterCreateBody.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterInitialProps } from "./clusterInitialProps"; + +export type ClusterCreateBody = ClusterInitialProps; diff --git a/web/src/api/openapi/schemas/clusterCreateOKResponse.ts b/web/src/api/openapi/schemas/clusterCreateOKResponse.ts new file mode 100644 index 000000000..06b17d503 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterCreateOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster created. + */ +export type ClusterCreateOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterDescription.ts b/web/src/api/openapi/schemas/clusterDescription.ts new file mode 100644 index 000000000..aa45c6d90 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterDescription.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +export type ClusterDescription = string; diff --git a/web/src/api/openapi/schemas/clusterGetOKResponse.ts b/web/src/api/openapi/schemas/clusterGetOKResponse.ts new file mode 100644 index 000000000..4b3b39f73 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterGetOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterWithItems } from "./clusterWithItems"; + +/** + * Cluster information and content. + */ +export type ClusterGetOKResponse = ClusterWithItems; diff --git a/web/src/api/openapi/schemas/clusterInitialProps.ts b/web/src/api/openapi/schemas/clusterInitialProps.ts new file mode 100644 index 000000000..5b2808db6 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterInitialProps.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ClusterDescription } from "./clusterDescription"; +import type { ClusterName } from "./clusterName"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +export interface ClusterInitialProps { + name: ClusterName; + slug: Slug; + image_url?: AssetURL; + description: ClusterDescription; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/clusterItem.ts b/web/src/api/openapi/schemas/clusterItem.ts new file mode 100644 index 000000000..b0a76b86f --- /dev/null +++ b/web/src/api/openapi/schemas/clusterItem.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Item } from "./item"; + +/** + * An item belonging to the enclosing cluster. + + */ +export type ClusterItem = Item; diff --git a/web/src/api/openapi/schemas/clusterItemList.ts b/web/src/api/openapi/schemas/clusterItemList.ts new file mode 100644 index 000000000..2dd8f4303 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterItemList.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterItem } from "./clusterItem"; + +/** + * A list of items within the context of belonging to a cluster. Different +from an ItemList because we do not need to include the parent cluster +information inside each item since it's already available. + + */ +export type ClusterItemList = ClusterItem[]; diff --git a/web/src/api/openapi/schemas/clusterList.ts b/web/src/api/openapi/schemas/clusterList.ts new file mode 100644 index 000000000..3b2eedf9a --- /dev/null +++ b/web/src/api/openapi/schemas/clusterList.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +export type ClusterList = Cluster[]; diff --git a/web/src/api/openapi/schemas/clusterListOKResponse.ts b/web/src/api/openapi/schemas/clusterListOKResponse.ts new file mode 100644 index 000000000..389abbb10 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterListOKResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterList } from "./clusterList"; + +export type ClusterListOKResponse = { + clusters: ClusterList; +}; diff --git a/web/src/api/openapi/schemas/clusterMutableProps.ts b/web/src/api/openapi/schemas/clusterMutableProps.ts new file mode 100644 index 000000000..2cd6349bb --- /dev/null +++ b/web/src/api/openapi/schemas/clusterMutableProps.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ClusterDescription } from "./clusterDescription"; +import type { ClusterName } from "./clusterName"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +/** + * Note: Properties are replace-all and are not merged with existing. + + */ +export interface ClusterMutableProps { + name?: ClusterName; + slug?: Slug; + image_url?: AssetURL; + description?: ClusterDescription; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/clusterName.ts b/web/src/api/openapi/schemas/clusterName.ts new file mode 100644 index 000000000..6fd5c717e --- /dev/null +++ b/web/src/api/openapi/schemas/clusterName.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +export type ClusterName = string; diff --git a/web/src/api/openapi/schemas/clusterRemoveChildOKResponse.ts b/web/src/api/openapi/schemas/clusterRemoveChildOKResponse.ts new file mode 100644 index 000000000..288c7f6c4 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterRemoveChildOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster child removed. Returns parent cluster. + */ +export type ClusterRemoveChildOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterRemoveItemOKResponse.ts b/web/src/api/openapi/schemas/clusterRemoveItemOKResponse.ts new file mode 100644 index 000000000..b83bb5df0 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterRemoveItemOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster content added. + */ +export type ClusterRemoveItemOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterSlug.ts b/web/src/api/openapi/schemas/clusterSlug.ts new file mode 100644 index 000000000..b7b753f01 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterSlug.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Slug } from "./slug"; + +export type ClusterSlug = Slug; diff --git a/web/src/api/openapi/schemas/clusterUpdateBody.ts b/web/src/api/openapi/schemas/clusterUpdateBody.ts new file mode 100644 index 000000000..c1aa9f113 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterUpdateBody.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterMutableProps } from "./clusterMutableProps"; + +export type ClusterUpdateBody = ClusterMutableProps; diff --git a/web/src/api/openapi/schemas/clusterUpdateOKResponse.ts b/web/src/api/openapi/schemas/clusterUpdateOKResponse.ts new file mode 100644 index 000000000..1216bb0c5 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterUpdateOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; + +/** + * Cluster updated. + */ +export type ClusterUpdateOKResponse = Cluster; diff --git a/web/src/api/openapi/schemas/clusterWithItems.ts b/web/src/api/openapi/schemas/clusterWithItems.ts new file mode 100644 index 000000000..5a7442717 --- /dev/null +++ b/web/src/api/openapi/schemas/clusterWithItems.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Cluster } from "./cluster"; +import type { ClusterWithItemsAllOf } from "./clusterWithItemsAllOf"; + +/** + * The full properties of a cluster including all items and maybe child +clusters (depending on what the endpoint is configured or queried to do) +for rendering a single cluster on a view. + + */ +export type ClusterWithItems = Cluster & ClusterWithItemsAllOf; diff --git a/web/src/api/openapi/schemas/clusterWithItemsAllOf.ts b/web/src/api/openapi/schemas/clusterWithItemsAllOf.ts new file mode 100644 index 000000000..ee42002cb --- /dev/null +++ b/web/src/api/openapi/schemas/clusterWithItemsAllOf.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterItemList } from "./clusterItemList"; +import type { ClusterList } from "./clusterList"; + +export type ClusterWithItemsAllOf = { + items: ClusterItemList; + clusters: ClusterList; +}; diff --git a/web/src/api/openapi/schemas/index.ts b/web/src/api/openapi/schemas/index.ts index 07367d920..0628afc45 100644 --- a/web/src/api/openapi/schemas/index.ts +++ b/web/src/api/openapi/schemas/index.ts @@ -31,6 +31,7 @@ export * from "./asset"; export * from "./assetGetOKResponse"; export * from "./assetID"; export * from "./assetList"; +export * from "./assetURL"; export * from "./assetUploadBody"; export * from "./assetUploadOKResponse"; export * from "./attestationConveyancePreference"; @@ -63,6 +64,28 @@ export * from "./categorySlugList"; export * from "./categoryUpdateBody"; export * from "./categoryUpdateOKResponse"; export * from "./categoryUpdateOrderBody"; +export * from "./cluster"; +export * from "./clusterAddChildOKResponse"; +export * from "./clusterAddItemOKResponse"; +export * from "./clusterCommonProps"; +export * from "./clusterCreateBody"; +export * from "./clusterCreateOKResponse"; +export * from "./clusterDescription"; +export * from "./clusterGetOKResponse"; +export * from "./clusterInitialProps"; +export * from "./clusterItem"; +export * from "./clusterItemList"; +export * from "./clusterList"; +export * from "./clusterListOKResponse"; +export * from "./clusterMutableProps"; +export * from "./clusterName"; +export * from "./clusterRemoveChildOKResponse"; +export * from "./clusterRemoveItemOKResponse"; +export * from "./clusterSlug"; +export * from "./clusterUpdateBody"; +export * from "./clusterUpdateOKResponse"; +export * from "./clusterWithItems"; +export * from "./clusterWithItemsAllOf"; export * from "./collection"; export * from "./collectionAddPostOKResponse"; export * from "./collectionCommonProps"; @@ -90,6 +113,22 @@ export * from "./getInfoOKResponse"; export * from "./identifier"; export * from "./info"; export * from "./internalServerErrorResponse"; +export * from "./item"; +export * from "./itemCommonProps"; +export * from "./itemCreateBody"; +export * from "./itemCreateOKResponse"; +export * from "./itemDescription"; +export * from "./itemGetOKResponse"; +export * from "./itemInitialProps"; +export * from "./itemList"; +export * from "./itemListOKResponse"; +export * from "./itemMutableProps"; +export * from "./itemName"; +export * from "./itemSlug"; +export * from "./itemUpdateBody"; +export * from "./itemUpdateOKResponse"; +export * from "./itemWithParents"; +export * from "./itemWithParentsAllOf"; export * from "./metadata"; export * from "./notFoundResponse"; export * from "./oAuthCallback"; @@ -117,6 +156,7 @@ export * from "./postUpdateBody"; export * from "./postUpdateOKResponse"; export * from "./profileGetOKResponse"; export * from "./profileReference"; +export * from "./properties"; export * from "./publicKeyCredential"; export * from "./publicKeyCredentialClientExtensionResults"; export * from "./publicKeyCredentialCreationOptions"; @@ -133,6 +173,7 @@ export * from "./publicProfileAllOf"; export * from "./react"; export * from "./reactList"; export * from "./residentKeyRequirement"; +export * from "./slug"; export * from "./tag"; export * from "./tagList"; export * from "./tagListIDs"; diff --git a/web/src/api/openapi/schemas/item.ts b/web/src/api/openapi/schemas/item.ts new file mode 100644 index 000000000..8bf86110d --- /dev/null +++ b/web/src/api/openapi/schemas/item.ts @@ -0,0 +1,23 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { CommonProperties } from "./commonProperties"; +import type { ItemCommonProps } from "./itemCommonProps"; + +/** + * An item is an arbitrary object used for indexing any kind of structured +data for the purposes of archival, search, documentation, products, etc. +Items are similar to posts in terms of data model but are semantically +different when it comes to purpose. + +If you were to use Storyden to run a community for a video game for +example, items could be used to represent actual items from the game +which allows members to search for them as well as reference them in +posts and other content. + + */ +export type Item = CommonProperties & ItemCommonProps; diff --git a/web/src/api/openapi/schemas/itemCommonProps.ts b/web/src/api/openapi/schemas/itemCommonProps.ts new file mode 100644 index 000000000..296f700b4 --- /dev/null +++ b/web/src/api/openapi/schemas/itemCommonProps.ts @@ -0,0 +1,25 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ItemDescription } from "./itemDescription"; +import type { ItemName } from "./itemName"; +import type { ProfileReference } from "./profileReference"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +/** + * The main properties for an item. + */ +export interface ItemCommonProps { + name: ItemName; + slug: Slug; + image_url?: AssetURL; + description: ItemDescription; + owner: ProfileReference; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/itemCreateBody.ts b/web/src/api/openapi/schemas/itemCreateBody.ts new file mode 100644 index 000000000..572ec1cd0 --- /dev/null +++ b/web/src/api/openapi/schemas/itemCreateBody.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ItemInitialProps } from "./itemInitialProps"; + +export type ItemCreateBody = ItemInitialProps; diff --git a/web/src/api/openapi/schemas/itemCreateOKResponse.ts b/web/src/api/openapi/schemas/itemCreateOKResponse.ts new file mode 100644 index 000000000..21a2d438c --- /dev/null +++ b/web/src/api/openapi/schemas/itemCreateOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Item } from "./item"; + +/** + * Item created. + */ +export type ItemCreateOKResponse = Item; diff --git a/web/src/api/openapi/schemas/itemDescription.ts b/web/src/api/openapi/schemas/itemDescription.ts new file mode 100644 index 000000000..57df3074d --- /dev/null +++ b/web/src/api/openapi/schemas/itemDescription.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +export type ItemDescription = string; diff --git a/web/src/api/openapi/schemas/itemGetOKResponse.ts b/web/src/api/openapi/schemas/itemGetOKResponse.ts new file mode 100644 index 000000000..9222135fa --- /dev/null +++ b/web/src/api/openapi/schemas/itemGetOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ItemWithParents } from "./itemWithParents"; + +/** + * Item information and content. + */ +export type ItemGetOKResponse = ItemWithParents; diff --git a/web/src/api/openapi/schemas/itemInitialProps.ts b/web/src/api/openapi/schemas/itemInitialProps.ts new file mode 100644 index 000000000..8ec07b0b9 --- /dev/null +++ b/web/src/api/openapi/schemas/itemInitialProps.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ItemDescription } from "./itemDescription"; +import type { ItemName } from "./itemName"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +export interface ItemInitialProps { + name: ItemName; + slug: Slug; + image_url?: AssetURL; + description: ItemDescription; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/itemList.ts b/web/src/api/openapi/schemas/itemList.ts new file mode 100644 index 000000000..b810a1dfb --- /dev/null +++ b/web/src/api/openapi/schemas/itemList.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ItemWithParents } from "./itemWithParents"; + +/** + * A list of items where each item includes all the information about its +parent cluster too. For use with APIs that want to provide a list of +items that may be part of different clusters. + + */ +export type ItemList = ItemWithParents[]; diff --git a/web/src/api/openapi/schemas/itemListOKResponse.ts b/web/src/api/openapi/schemas/itemListOKResponse.ts new file mode 100644 index 000000000..61358192a --- /dev/null +++ b/web/src/api/openapi/schemas/itemListOKResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ItemList } from "./itemList"; + +export type ItemListOKResponse = { + clusters: ItemList; +}; diff --git a/web/src/api/openapi/schemas/itemMutableProps.ts b/web/src/api/openapi/schemas/itemMutableProps.ts new file mode 100644 index 000000000..cee284a1e --- /dev/null +++ b/web/src/api/openapi/schemas/itemMutableProps.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { AssetURL } from "./assetURL"; +import type { ItemDescription } from "./itemDescription"; +import type { ItemName } from "./itemName"; +import type { Properties } from "./properties"; +import type { Slug } from "./slug"; + +/** + * Note: Properties are replace-all and are not merged with existing. + + */ +export interface ItemMutableProps { + name?: ItemName; + slug?: Slug; + image_url?: AssetURL; + description?: ItemDescription; + properties?: Properties; +} diff --git a/web/src/api/openapi/schemas/itemName.ts b/web/src/api/openapi/schemas/itemName.ts new file mode 100644 index 000000000..331dd739d --- /dev/null +++ b/web/src/api/openapi/schemas/itemName.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +export type ItemName = string; diff --git a/web/src/api/openapi/schemas/itemSlug.ts b/web/src/api/openapi/schemas/itemSlug.ts new file mode 100644 index 000000000..e290c0484 --- /dev/null +++ b/web/src/api/openapi/schemas/itemSlug.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Slug } from "./slug"; + +export type ItemSlug = Slug; diff --git a/web/src/api/openapi/schemas/itemUpdateBody.ts b/web/src/api/openapi/schemas/itemUpdateBody.ts new file mode 100644 index 000000000..95a3a1c10 --- /dev/null +++ b/web/src/api/openapi/schemas/itemUpdateBody.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ItemMutableProps } from "./itemMutableProps"; + +export type ItemUpdateBody = ItemMutableProps; diff --git a/web/src/api/openapi/schemas/itemUpdateOKResponse.ts b/web/src/api/openapi/schemas/itemUpdateOKResponse.ts new file mode 100644 index 000000000..d609b2b32 --- /dev/null +++ b/web/src/api/openapi/schemas/itemUpdateOKResponse.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { Item } from "./item"; + +/** + * Item updated. + */ +export type ItemUpdateOKResponse = Item; diff --git a/web/src/api/openapi/schemas/itemWithParents.ts b/web/src/api/openapi/schemas/itemWithParents.ts new file mode 100644 index 000000000..65246d61b --- /dev/null +++ b/web/src/api/openapi/schemas/itemWithParents.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { CommonProperties } from "./commonProperties"; +import type { ItemCommonProps } from "./itemCommonProps"; +import type { ItemWithParentsAllOf } from "./itemWithParentsAllOf"; + +/** + * Represents an item with the parent cluster information included. Used by +schemas that only want a single item along with its cluster information. + + */ +export type ItemWithParents = CommonProperties & + ItemCommonProps & + ItemWithParentsAllOf; diff --git a/web/src/api/openapi/schemas/itemWithParentsAllOf.ts b/web/src/api/openapi/schemas/itemWithParentsAllOf.ts new file mode 100644 index 000000000..79d3b8d33 --- /dev/null +++ b/web/src/api/openapi/schemas/itemWithParentsAllOf.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ +import type { ClusterList } from "./clusterList"; + +export type ItemWithParentsAllOf = { + clusters?: ClusterList; +}; diff --git a/web/src/api/openapi/schemas/properties.ts b/web/src/api/openapi/schemas/properties.ts new file mode 100644 index 000000000..f76dc23e6 --- /dev/null +++ b/web/src/api/openapi/schemas/properties.ts @@ -0,0 +1,23 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +/** + * Arbitrary JSON object that can express any additional data for a +resource object. This is intended for client implementations to use for +extending objects with arbitrary information to satisfy product needs. + +For example, if you were building a book database, you could use the +Properties of a cluster to specify publisher information such as date of +founding, headquarters, size, etc. and then use the Properties of the +items in that cluster to specify book information such as release date, +number of pages, etc. + + */ +export interface Properties { + [key: string]: any; +} diff --git a/web/src/api/openapi/schemas/slug.ts b/web/src/api/openapi/schemas/slug.ts new file mode 100644 index 000000000..968f0e439 --- /dev/null +++ b/web/src/api/openapi/schemas/slug.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.17.0 🍺 + * Do not edit manually. + * storyden + * Storyden social API for building community driven platforms. + * OpenAPI spec version: 1 + */ + +/** + * A URL-safe slug for uniquely identifying resources. + */ +export type Slug = string;