Current section

Files

Jump to
fireball src objects@storage.erl
Raw

src/objects@storage.erl

-module(objects@storage).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([upload_data_to_json/1, json_to_upload_data/1]).
-export_type([fireball_storage/0, upload_data/0]).
-type fireball_storage() :: {fireball_storage, binary()}.
-type upload_data() :: {upload_data,
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary()}.
-file("/export/gleam/fireball/src/objects/storage.gleam", 34).
-spec upload_data_to_json(upload_data()) -> binary().
upload_data_to_json(Upload_data) ->
_pipe = gleam@json:object(
[{<<"name"/utf8>>, gleam@json:string(erlang:element(2, Upload_data))},
{<<"bucket"/utf8>>,
gleam@json:string(erlang:element(3, Upload_data))},
{<<"generation"/utf8>>,
gleam@json:string(erlang:element(4, Upload_data))},
{<<"metageneration"/utf8>>,
gleam@json:string(erlang:element(5, Upload_data))},
{<<"contentType"/utf8>>,
gleam@json:string(erlang:element(6, Upload_data))},
{<<"timeCreated"/utf8>>,
gleam@json:string(erlang:element(7, Upload_data))},
{<<"updated"/utf8>>,
gleam@json:string(erlang:element(8, Upload_data))},
{<<"storageClass"/utf8>>,
gleam@json:string(erlang:element(9, Upload_data))},
{<<"size"/utf8>>,
gleam@json:string(erlang:element(10, Upload_data))},
{<<"md5Hash"/utf8>>,
gleam@json:string(erlang:element(11, Upload_data))},
{<<"contentEncoding"/utf8>>,
gleam@json:string(erlang:element(12, Upload_data))},
{<<"contentDisposition"/utf8>>,
gleam@json:string(erlang:element(13, Upload_data))},
{<<"crc32c"/utf8>>,
gleam@json:string(erlang:element(14, Upload_data))},
{<<"etag"/utf8>>,
gleam@json:string(erlang:element(15, Upload_data))},
{<<"downloadTokens"/utf8>>,
gleam@json:string(erlang:element(16, Upload_data))}]
),
gleam@json:to_string(_pipe).
-file("/export/gleam/fireball/src/objects/storage.gleam", 56).
-spec json_to_upload_data(gleam@dynamic:dynamic_()) -> {ok, upload_data()} |
{error, list(gleam@dynamic:decode_error())}.
json_to_upload_data(Input) ->
Decoder = (decode@zero:field(
<<"name"/utf8>>,
{decoder, fun decode@zero:decode_string/1},
fun(Name) ->
decode@zero:field(
<<"bucket"/utf8>>,
{decoder, fun decode@zero:decode_string/1},
fun(Bucket) ->
decode@zero:field(
<<"generation"/utf8>>,
{decoder, fun decode@zero:decode_string/1},
fun(Generation) ->
decode@zero:field(
<<"metageneration"/utf8>>,
{decoder, fun decode@zero:decode_string/1},
fun(Metageneration) ->
decode@zero:field(
<<"contentType"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(Content_type) ->
decode@zero:field(
<<"timeCreated"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(Time_created) ->
decode@zero:field(
<<"updated"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(Updated) ->
decode@zero:field(
<<"storageClass"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Storage_class
) ->
decode@zero:field(
<<"size"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Size
) ->
decode@zero:field(
<<"md5Hash"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Md5_hash
) ->
decode@zero:field(
<<"contentEncoding"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Content_encoding
) ->
decode@zero:field(
<<"contentDisposition"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Content_disposition
) ->
decode@zero:field(
<<"crc32c"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Crc32c
) ->
decode@zero:field(
<<"etag"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Etag
) ->
decode@zero:field(
<<"downloadTokens"/utf8>>,
{decoder,
fun decode@zero:decode_string/1},
fun(
Download_tokens
) ->
decode@zero:success(
{upload_data,
Name,
Bucket,
Generation,
Metageneration,
Content_type,
Time_created,
Updated,
Storage_class,
Size,
Md5_hash,
Content_encoding,
Content_disposition,
Crc32c,
Etag,
Download_tokens}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)),
decode@zero:run(Input, Decoder).