wire-api-0.1.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Wire.API.Routes.Public.Cargohold

Synopsis

Documentation

data PrincipalTag Source #

Instances

Instances details
Show PrincipalTag Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

Eq PrincipalTag Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

RoutesToPaths (ApplyPrincipalPath tag api) => RoutesToPaths (tag :> api :: Type) Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

HasServer (ApplyPrincipalPath tag api) ctx => HasServer (tag :> api :: Type) ctx Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

Associated Types

type ServerT (tag :> api) m Source #

Methods

route :: Proxy (tag :> api) -> Context ctx -> Delayed env (Server (tag :> api)) -> Router env Source #

hoistServerWithContext :: Proxy (tag :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (tag :> api) m -> ServerT (tag :> api) n Source #

type SpecialiseToVersion v (tag :> api) Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

type ServerT (tag :> api :: Type) m Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

type ServerT (tag :> api :: Type) m = ServerT (ApplyPrincipalPath tag api) m

type family ApplyPrincipalPath (tag :: PrincipalTag) api Source #

Instances

Instances details
type ApplyPrincipalPath 'BotPrincipalTag api Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

type ApplyPrincipalPath 'BotPrincipalTag api = ZBot :> ("bot" :> ("assets" :> api))
type ApplyPrincipalPath 'ProviderPrincipalTag api Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

type ApplyPrincipalPath 'ProviderPrincipalTag api = ZProvider :> ("provider" :> ("assets" :> api))
type ApplyPrincipalPath 'UserPrincipalTag api Source # 
Instance details

Defined in Wire.API.Routes.Public.Cargohold

type ApplyPrincipalPath 'UserPrincipalTag api = ZLocalUser :> (Until 'V2 :> ("assets" :> ("v3" :> api)))

type AssetLocationHeader r = '[DescHeader "Location" "Asset location" (AssetLocation r)] Source #

type AssetStreaming = RespondStreaming 200 "Asset returned directly with content type `application/octet-stream`" OctetStream Source #

type CargoholdAPI = (Summary "Renew an asset token" :> (Until 'V2 :> (CanThrow 'AssetNotFound :> (CanThrow 'Unauthorised :> (ZLocalUser :> ("assets" :> ("v3" :> (Capture "key" AssetKey :> ("token" :> Post '[JSON] NewAssetToken))))))))) :<|> ((Summary "Delete an asset token" :> (Until 'V2 :> (Description "**Note**: deleting the token makes the asset public." :> (ZLocalUser :> ("assets" :> ("v3" :> (Capture "key" AssetKey :> ("token" :> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Asset token deleted"] ())))))))) :<|> (BaseAPIv3 'UserPrincipalTag :<|> (BaseAPIv3 'BotPrincipalTag :<|> (BaseAPIv3 'ProviderPrincipalTag :<|> (QualifiedAPI :<|> (LegacyAPI :<|> MainAPI)))))) Source #

type BaseAPIv3 (tag :: PrincipalTag) = (Summary "Upload an asset" :> (CanThrow 'AssetTooLarge :> (CanThrow 'InvalidLength :> (tag :> (AssetBody :> MultiVerb 'POST '[JSON] '[WithHeaders (AssetLocationHeader Relative) (Asset, AssetLocation Relative) (Respond 201 "Asset posted" Asset)] (Asset, AssetLocation Relative)))))) :<|> ((Summary "Download an asset" :> (tag :> (Capture "key" AssetKey :> (Header "Asset-Token" AssetToken :> (QueryParam "asset_token" AssetToken :> (ZHostOpt :> GetAsset)))))) :<|> (Summary "Delete an asset" :> (CanThrow 'AssetNotFound :> (CanThrow 'Unauthorised :> (tag :> (Capture "key" AssetKey :> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Asset deleted"] ())))))) Source #

Asset API for a given principal (userbotprovider).

This was introduced before API versioning, and the user endpoints contain a v3 suffix, which is removed starting from API V2.

type QualifiedAPI = (Summary "Download an asset" :> (Until 'V2 :> (Description "**Note**: local assets result in a redirect, while remote assets are streamed directly." :> (ZLocalUser :> ("assets" :> ("v4" :> (QualifiedCapture "key" AssetKey :> (Header "Asset-Token" AssetToken :> (QueryParam "asset_token" AssetToken :> (ZHostOpt :> MultiVerb 'GET '() '[ErrorResponse 'AssetNotFound, AssetRedirect, AssetStreaming] (Maybe LocalOrRemoteAsset))))))))))) :<|> (Summary "Delete an asset" :> (Until 'V2 :> (Description "**Note**: only local assets can be deleted." :> (CanThrow 'AssetNotFound :> (CanThrow 'Unauthorised :> (ZLocalUser :> ("assets" :> ("v4" :> (QualifiedCapture "key" AssetKey :> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Asset deleted"] ()))))))))) Source #

Qualified asset API. Only download and delete endpoints are supported, as upload has stayed unqualified. These endpoints also predate API versioning, and contain a v4 suffix.

type LegacyAPI = (ZLocalUser :> (Until 'V2 :> ("assets" :> (QueryParam' [Required, Strict] "conv_id" ConvId :> (Capture "id" AssetId :> GetAsset))))) :<|> ((ZLocalUser :> (Until 'V2 :> ("conversations" :> (Capture "cnv" ConvId :> ("assets" :> (Capture "id" AssetId :> GetAsset)))))) :<|> (ZLocalUser :> (Until 'V2 :> ("conversations" :> (Capture "cnv" ConvId :> ("otr" :> ("assets" :> (Capture "id" AssetId :> GetAsset)))))))) Source #

type MainAPI = (Summary "Renew an asset token" :> (From 'V2 :> (CanThrow 'AssetNotFound :> (CanThrow 'Unauthorised :> (ZLocalUser :> ("assets" :> (Capture "key" AssetKey :> ("token" :> Post '[JSON] NewAssetToken)))))))) :<|> ((Summary "Delete an asset token" :> (From 'V2 :> (Description "**Note**: deleting the token makes the asset public." :> (ZLocalUser :> ("assets" :> (Capture "key" AssetKey :> ("token" :> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Asset token deleted"] ()))))))) :<|> ((Summary "Upload an asset" :> (From 'V2 :> (CanThrow 'AssetTooLarge :> (CanThrow 'InvalidLength :> (ZLocalUser :> ("assets" :> (AssetBody :> MultiVerb 'POST '[JSON] '[WithHeaders (AssetLocationHeader Relative) (Asset, AssetLocation Relative) (Respond 201 "Asset posted" Asset)] (Asset, AssetLocation Relative)))))))) :<|> ((Summary "Download an asset" :> (From 'V2 :> (Description "**Note**: local assets result in a redirect, while remote assets are streamed directly." :> (CanThrow 'NoMatchingAssetEndpoint :> (ZLocalUser :> ("assets" :> (QualifiedCapture "key" AssetKey :> (Header "Asset-Token" AssetToken :> (QueryParam "asset_token" AssetToken :> (ZHostOpt :> MultiVerb 'GET '() '[ErrorResponse 'AssetNotFound, AssetRedirect, AssetStreaming] (Maybe LocalOrRemoteAsset))))))))))) :<|> (Summary "Delete an asset" :> (From 'V2 :> (Description "**Note**: only local assets can be deleted." :> (CanThrow 'AssetNotFound :> (CanThrow 'Unauthorised :> (ZLocalUser :> ("assets" :> (QualifiedCapture "key" AssetKey :> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Asset deleted"] ()))))))))))) Source #

With API versioning, the previous ad-hoc v3/v4 versioning is abandoned, and asset endpoints are versioned normally as part of the public API, without any explicit prefix.