2023-01-10 16:02:56 +00:00
|
|
|
// project contains information about a user project.
|
2023-01-06 16:27:42 +00:00
|
|
|
model project (
|
|
|
|
key id
|
|
|
|
|
|
|
|
index (
|
|
|
|
name projects_public_id_index
|
|
|
|
fields public_id
|
|
|
|
)
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// id is a UUID used for identifying the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field id blob
|
2023-01-10 16:02:56 +00:00
|
|
|
// public_id is a UUID that's used in web requests.
|
2023-01-06 16:27:42 +00:00
|
|
|
field public_id blob ( nullable )
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// name is a identifier that's shown to the user.
|
2023-01-06 16:27:42 +00:00
|
|
|
field name text ( updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// description helps users to clarify what the project is for.
|
2023-01-06 16:27:42 +00:00
|
|
|
field description text ( updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// usage_limit defines maximum allowed bytes that can be stored.
|
2023-01-06 16:27:42 +00:00
|
|
|
field usage_limit int64 ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// bandwidth_limit defines maximum allowed bandwidth per month in bytes.
|
2023-01-06 16:27:42 +00:00
|
|
|
field bandwidth_limit int64 ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// user_specified_usage_limit is set by the user to limit their bytes that can be stored.
|
2023-01-06 16:27:42 +00:00
|
|
|
field user_specified_usage_limit int64 ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// user_specified_bandwidth_limit is set by the user to limit their bytes that downloaded.
|
2023-01-06 16:27:42 +00:00
|
|
|
field user_specified_bandwidth_limit int64 ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// segment_limit specifies how many segments can be stored in the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field segment_limit int64 ( nullable, updatable, default 1000000)
|
2023-01-10 16:02:56 +00:00
|
|
|
// rate_limit defines maximum requests per second the project can use.
|
|
|
|
// See golang.org/x/time/rate#Limiter for details.
|
2023-01-06 16:27:42 +00:00
|
|
|
field rate_limit int ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// burst_limit defines number of requests that are not throttled by rate_limit.
|
|
|
|
// See golang.org/x/time/rate#Limiter for details.
|
2023-01-06 16:27:42 +00:00
|
|
|
field burst_limit int ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// max_buckets is the maximum number of buckets that can be created for the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field max_buckets int ( nullable, updatable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// partner_id is an UUID that refers to rewards.PartnersStaticDB.
|
|
|
|
// deprecated: use user_agent instead.
|
2023-01-06 16:27:42 +00:00
|
|
|
field partner_id blob ( nullable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// user_agent is the referred partner who created the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field user_agent blob ( nullable )
|
2023-01-10 16:02:56 +00:00
|
|
|
// owner_id refers to the user UUID in user.id.
|
2023-01-06 16:27:42 +00:00
|
|
|
field owner_id blob
|
2023-01-10 16:02:56 +00:00
|
|
|
// salt is used for salting the user passphrase for the content.
|
2023-01-06 16:27:42 +00:00
|
|
|
field salt blob ( nullable )
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// created_at indicates when the project was created.
|
2023-01-06 16:27:42 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create project ( )
|
|
|
|
update project ( where project.id = ? )
|
|
|
|
delete project ( where project.id = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select project.salt
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project
|
|
|
|
where project.public_id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.usage_limit
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.bandwidth_limit
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.user_specified_usage_limit
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.user_specified_bandwidth_limit
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.segment_limit
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project.max_buckets
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
2023-03-13 16:55:30 +00:00
|
|
|
select project.bandwidth_limit project.usage_limit project.segment_limit project.rate_limit project.burst_limit
|
2023-01-06 16:27:42 +00:00
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
where project.created_at < ?
|
|
|
|
orderby asc project.created_at
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
where project.owner_id = ?
|
|
|
|
orderby asc project.created_at
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
join project.id = project_member.project_id
|
|
|
|
where project_member.member_id = ?
|
|
|
|
orderby asc project.name
|
|
|
|
)
|
|
|
|
|
|
|
|
read limitoffset (
|
|
|
|
select project
|
|
|
|
where project.created_at < ?
|
|
|
|
orderby asc project.created_at
|
|
|
|
)
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// project_member is an association table between projects and users.
|
|
|
|
// It indicates which users have access to the specific project.
|
2023-01-06 16:27:42 +00:00
|
|
|
model project_member (
|
|
|
|
key member_id project_id
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// member_id is the user that can access the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field member_id user.id cascade
|
2023-01-10 16:02:56 +00:00
|
|
|
// project_id is the project that can be accessed.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_id project.id cascade
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// created_at indicates when the user was added as a member.
|
2023-01-06 16:27:42 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create project_member ( )
|
|
|
|
delete project_member (
|
|
|
|
where project_member.member_id = ?
|
|
|
|
where project_member.project_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select project_member
|
|
|
|
where project_member.member_id = ?
|
|
|
|
)
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// api_key is used to authenticate in requests.
|
2023-01-06 16:27:42 +00:00
|
|
|
model api_key (
|
|
|
|
key id
|
|
|
|
unique head
|
|
|
|
unique name project_id
|
|
|
|
|
2023-01-10 16:02:56 +00:00
|
|
|
// id is a UUID for the api key.
|
2023-01-06 16:27:42 +00:00
|
|
|
field id blob
|
2023-01-10 16:02:56 +00:00
|
|
|
// project_id is a UUID that refers to project.id.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_id project.id cascade
|
2023-01-10 16:02:56 +00:00
|
|
|
// head is restrictions for the api key.
|
2023-01-06 16:27:42 +00:00
|
|
|
field head blob
|
2023-01-10 16:02:56 +00:00
|
|
|
// name helps users to identify the purpose of the api key.
|
2023-01-06 16:27:42 +00:00
|
|
|
field name text (updatable)
|
2023-01-10 16:02:56 +00:00
|
|
|
// secret is the macaroon secret.
|
2023-01-06 16:27:42 +00:00
|
|
|
field secret blob
|
2023-01-10 16:02:56 +00:00
|
|
|
// partner_id is an UUID that refers to rewards.PartnersStaticDB.
|
|
|
|
// deprecated: use user_agent instead.
|
2023-01-06 16:27:42 +00:00
|
|
|
field partner_id blob (nullable)
|
2023-01-10 16:02:56 +00:00
|
|
|
// user_agent is the referred partner who created the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field user_agent blob (nullable)
|
2023-01-10 16:02:56 +00:00
|
|
|
// created_at indicates when the api key was added.
|
2023-01-06 16:27:42 +00:00
|
|
|
field created_at timestamp (autoinsert)
|
|
|
|
)
|
|
|
|
|
|
|
|
create api_key ( )
|
|
|
|
update api_key (
|
|
|
|
where api_key.id = ?
|
|
|
|
noreturn
|
|
|
|
)
|
|
|
|
delete api_key ( where api_key.id = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select api_key
|
|
|
|
where api_key.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select api_key
|
|
|
|
where api_key.head = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select api_key
|
|
|
|
where api_key.name = ?
|
|
|
|
where api_key.project_id = ?
|
|
|
|
)
|