Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-audi committed Nov 13, 2022
2 parents d2509f6 + 9414a19 commit 8526a86
Show file tree
Hide file tree
Showing 50 changed files with 13,883 additions and 2,335 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*.*.*'

permissions:
contents: read
contents: write
pages: write
id-token: write

Expand All @@ -32,3 +32,5 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Release
uses: softprops/action-gh-release@v1
22 changes: 11 additions & 11 deletions database/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
-- API ID
-- -----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS api_id(
api_id UUID PRIMARY KEY,
customer_id TEXT NOT NULL,
aid UUID PRIMARY KEY,
uid TEXT NOT NULL,
is_valid BOOLEAN NOT NULL DEFAULT FALSE,
created_utc TIMESTAMP WITH TIME ZONE NOT NULL,
modified_utc TIMESTAMP WITH TIME ZONE NOT NULL
);

-- -----------------------------------------------------------------------
-- POLICY
-- TOKEN
-- -----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS policy(
policy_id BIGSERIAL NOT NULL,
api_id uuid NOT NULL,
CREATE TABLE IF NOT EXISTS token(
tid UUID PRIMARY KEY,
aid UUID NOT NULL,
urn_prefix TEXT NOT NULL,
created_utc TIMESTAMP WITH TIME ZONE NOT NULL,
FOREIGN KEY(api_id) REFERENCES api_id(api_id)
FOREIGN KEY(aid) REFERENCES api_id(aid)
);

-- -----------------------------------------------------------------------
-- USAGE
-- REPORT
-- -----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS usage(
usage_id BIGSERIAL NOT NULL,
CREATE TABLE IF NOT EXISTS report(
rid BIGSERIAL PRIMARY KEY,
urn_prefix TEXT NOT NULL,
size_bytes BIGINT,
created_utc TIMESTAMP WITH TIME ZONE NOT NULL
);
CREATE INDEX idx_usage_log_urn_created ON usage (urn_prefix, created_utc);
CREATE INDEX idx_usage_log_urn_created ON report (urn_prefix, created_utc);
157 changes: 57 additions & 100 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,88 +1,49 @@
openapi: 3.0.1
info:
title: L0 Storage
description: Immutable Block Storage
description: Long-term immutable storage
license:
name: MIT
url: https://github.com/tiki/l0-storage/blob/main/LICENSE
version: 0.0.11
version: 0.0.12
servers:
- url: https://storage.l0.mytiki.com
paths:
/api/latest/upload:
post:
tags:
- UPLOAD
- STORAGE
summary: Upload a block
operationId: post
requestBody:
content:
multipart/form-data:
application/json:
schema:
required:
- content-md5
- content-type
- file
- key
- policy
- x-amz-algorithm
- x-amz-credential
- x-amz-date
- x-amz-object-lock-mode
- x-amz-object-lock-retain-until-date
- x-amz-signature
type: object
properties:
policy:
type: string
content-type:
type: string
x-amz-credential:
type: string
x-amz-algorithm:
type: string
x-amz-date:
type: string
x-amz-signature:
type: string
x-amz-object-lock-mode:
type: string
x-amz-object-lock-retain-until-date:
type: string
key:
type: string
content-md5:
type: string
file:
block:
type: string
format: binary
responses:
"204":
description: No Content
/api/latest/usage:
"201":
description: Created
"400":
description: Bad Request
"401":
description: Unauthorized
"405":
description: Method Not Allowed
"413":
description: Payload Too Large
"424":
description: Failed Dependency
/api/latest/token:
post:
tags:
- USAGE
summary: Submit a usage report
- STORAGE
summary: Request a new token
operationId: post_1
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UsageAOReq'
required: true
responses:
"204":
description: No Content
"403":
description: Forbidden
security:
- remote: []
/api/latest/policy:
post:
tags:
- POLICY
summary: Request a new policy
operationId: post_2
parameters:
- name: x-api-id
in: header
Expand All @@ -93,15 +54,15 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyAOReq'
$ref: '#/components/schemas/TokenAOReq'
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyAORsp'
$ref: '#/components/schemas/TokenAORsp'
"400":
description: Bad Request
"403":
Expand All @@ -110,6 +71,25 @@ paths:
description: Expectation Failed
security:
- apiId: []
/api/latest/report:
post:
tags:
- STORAGE
summary: Submit a usage report
operationId: post_2
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ReportAOReq'
required: true
responses:
"204":
description: No Content
"403":
description: Forbidden
security:
- remote: []
/api/latest/api-id/new:
post:
tags:
Expand Down Expand Up @@ -216,50 +196,19 @@ paths:
- jwt: []
components:
schemas:
UsageAOReq:
type: object
properties:
path:
type: string
sizeBytes:
type: integer
format: int64
PolicyAORsp:
type: object
properties:
expires:
type: string
keyPrefix:
type: string
maxBytes:
type: integer
format: int64
compute:
type: array
items:
type: string
fields:
$ref: '#/components/schemas/PolicyAORspFields'
PolicyAORspFields:
TokenAORsp:
type: object
properties:
policy:
type: string
content-type:
type: string
x-amz-credential:
type: string
x-amz-algorithm:
type: string
x-amz-date:
type:
type: string
x-amz-signature:
token:
type: string
x-amz-object-lock-mode:
expires:
type: string
x-amz-object-lock-retain-until-date:
format: date-time
urnPrefix:
type: string
PolicyAOReq:
TokenAOReq:
type: object
properties:
pubKey:
Expand All @@ -268,6 +217,14 @@ components:
type: string
stringToSign:
type: string
ReportAOReq:
type: object
properties:
path:
type: string
sizeBytes:
type: integer
format: int64
ApiIdAORsp:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.mytiki</groupId>
<artifactId>l0_storage</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
<packaging>jar</packaging>

<name>L0 Storage</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
package com.mytiki.l0_storage.features.latest;

import com.mytiki.l0_storage.features.latest.api_id.ApiIdConfig;
import com.mytiki.l0_storage.features.latest.policy.PolicyConfig;
import com.mytiki.l0_storage.features.latest.usage.UsageConfig;
import com.mytiki.l0_storage.features.latest.token.TokenConfig;
import com.mytiki.l0_storage.features.latest.report.ReportConfig;
import org.springframework.context.annotation.Import;

@Import({
ApiIdConfig.class,
PolicyConfig.class,
UsageConfig.class
TokenConfig.class,
ReportConfig.class
})
public class FeaturesConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -54,7 +53,6 @@ public ApiIdAORsp getKey(
@ApiResponse(responseCode = "200", description = "OK", content = @Content(
schema = @Schema(implementation = ApiIdAORsp.class))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content)})
@ResponseStatus(code = HttpStatus.NOT_FOUND)
@RequestMapping(method = RequestMethod.DELETE, path = PATH_ID + "/{api-id}")
public ApiIdAORsp deleteKey(
Authentication authentication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
@Entity
@Table(name = "api_id")
public class ApiIdDO implements Serializable {
private UUID apiId;
private String customerId;
private UUID aid;
private String uid;
private Boolean valid;
private ZonedDateTime created;
private ZonedDateTime modified;

@Id
@Column(name = "api_id")
@Column(name = "aid")
@org.hibernate.annotations.Type(type="org.hibernate.type.PostgresUUIDType")
public UUID getApiId() {
return apiId;
public UUID getAid() {
return aid;
}

public void setApiId(UUID apiId) {
this.apiId = apiId;
public void setAid(UUID aid) {
this.aid = aid;
}

@Column(name = "customer_id")
public String getCustomerId() {
return customerId;
@Column(name = "uid")
public String getUid() {
return uid;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
public void setUid(String uid) {
this.uid = uid;
}

@Column(name = "is_valid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

@Repository
public interface ApiIdRepository extends JpaRepository<ApiIdDO, UUID> {
Page<ApiIdDO> findAllByCustomerId(String customerId, Pageable pageable);
Page<ApiIdDO> findAllByUid(String uid, Pageable pageable);
}
Loading

0 comments on commit 8526a86

Please sign in to comment.