Documentation
¶
Overview ¶
Copyright 2024 Pantacor Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type Repo
- func (r *Repo) CountManyByOwner(ctx context.Context, ownerID string, filters bson.M) (int64, error)
- func (r *Repo) Create(ctx context.Context, token *tokenmodels.AuthToken, opts ...RepoWriteOpts) error
- func (r *Repo) DeleteToken(ctx context.Context, id string) error
- func (r *Repo) GetPagination(ctx context.Context, ownerID string, filters bson.M, aspUrl *url.URL, ...) querymongo.Pagination
- func (r *Repo) GetToken(ctx context.Context, id string) (*tokenmodels.AuthToken, error)
- func (r *Repo) GetTokensByOwner(ctx context.Context, owner string, asp querymongo.ApiSearchPagination) ([]tokenmodels.AuthToken, error)
- func (r *Repo) SaveToken(ctx context.Context, token *tokenmodels.AuthToken, opts ...RepoWriteOpts) error
- func (r *Repo) SetIndexes() error
- type RepoWriteOpts
Constants ¶
const ( // DBCollection db collection name for user tokens DBCollection = "pantahub_auth_tokens" // Prn name convection for the prn Prn = "prn:::tokens:/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) CountManyByOwner ¶
CountManyByOwner counts the number of documents in the collection based on the owner ID and filters.
Parameters: - ctx: the context in which the function is executed - ownerID: the ID of the owner - filters: the filters to apply to the query Return type: - int64: the count of documents - error: an error if the operation fails
func (*Repo) Create ¶
func (r *Repo) Create(ctx context.Context, token *tokenmodels.AuthToken, opts ...RepoWriteOpts) error
Create saves the authentication token in the repository.
Parameters: - ctx: the context in which the function is executed - token: the authentication token to save - opts: optional parameters for write operations Return type: error
func (*Repo) GetPagination ¶
func (r *Repo) GetPagination(ctx context.Context, ownerID string, filters bson.M, aspUrl *url.URL, elements []tokenmodels.AuthToken) querymongo.Pagination
GetPagination retrieves pagination information based on the provided owner ID, filters, URL, and elements.
Parameters: - ctx: the context in which the function is executed - ownerID: the ID of the owner - filters: the filters to apply to the query - aspUrl: the URL for pagination - elements: a list of authentication tokens Return type: - querymongo.Pagination: the pagination information
func (*Repo) GetToken ¶
GetToken retrieves an authentication token by ID.
Parameters: - ctx: the context in which the function is executed - id: the unique identifier of the token Return type: - *tokenmodels.AuthToken: the retrieved token information - error: an error if the operation fails
func (*Repo) GetTokensByOwner ¶
func (r *Repo) GetTokensByOwner(ctx context.Context, owner string, asp querymongo.ApiSearchPagination) ([]tokenmodels.AuthToken, error)
GetTokensByOwner retrieves tokens for a specific owner based on the provided search parameters.
Parameters: - ctx: the context in which the function is executed - owner: the unique identifier of the owner - asp: the search pagination parameters
Returns: - []tokenmodels.AuthToken: a list of authentication tokens - error: an error if the operation fails
func (*Repo) SaveToken ¶
func (r *Repo) SaveToken(ctx context.Context, token *tokenmodels.AuthToken, opts ...RepoWriteOpts) error
SaveToken saves the authentication token in the repository.
Parameters: - ctx: the context in which the function is executed - token: the authentication token to save - opts: optional parameters for write operations Return type: error
func (*Repo) SetIndexes ¶
SetIndexes sets up indexes in the repository collection.
No parameters. Return type: error.
type RepoWriteOpts ¶
type RepoWriteOpts struct {
Upsert bool
}