github.com/TrueCloudLab/frostfs-api-go/v2@v2.0.0-20230228134343-196241c4e79a/session/json.go (about) 1 package session 2 3 import ( 4 "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/message" 5 session "github.com/TrueCloudLab/frostfs-api-go/v2/session/grpc" 6 "google.golang.org/protobuf/encoding/protojson" 7 ) 8 9 func (c *ObjectSessionContext) MarshalJSON() ([]byte, error) { 10 return message.MarshalJSON(c) 11 } 12 13 func (c *ObjectSessionContext) UnmarshalJSON(data []byte) error { 14 return message.UnmarshalJSON(c, data, new(session.ObjectSessionContext)) 15 } 16 17 func (l *TokenLifetime) MarshalJSON() ([]byte, error) { 18 return message.MarshalJSON(l) 19 } 20 21 func (l *TokenLifetime) UnmarshalJSON(data []byte) error { 22 return message.UnmarshalJSON(l, data, new(session.SessionToken_Body_TokenLifetime)) 23 } 24 25 func (t *TokenBody) MarshalJSON() ([]byte, error) { 26 return message.MarshalJSON(t) 27 } 28 29 func (t *TokenBody) UnmarshalJSON(data []byte) error { 30 msg := new(session.SessionToken_Body) 31 32 if err := protojson.Unmarshal(data, msg); err != nil { 33 return err 34 } 35 36 return t.FromGRPCMessage(msg) 37 } 38 39 func (t *Token) MarshalJSON() ([]byte, error) { 40 return message.MarshalJSON(t) 41 } 42 43 func (t *Token) UnmarshalJSON(data []byte) error { 44 msg := new(session.SessionToken) 45 46 if err := protojson.Unmarshal(data, msg); err != nil { 47 return err 48 } 49 50 return t.FromGRPCMessage(msg) 51 } 52 53 func (x *XHeader) MarshalJSON() ([]byte, error) { 54 return message.MarshalJSON(x) 55 } 56 57 func (x *XHeader) UnmarshalJSON(data []byte) error { 58 msg := new(session.XHeader) 59 60 if err := protojson.Unmarshal(data, msg); err != nil { 61 return err 62 } 63 64 return x.FromGRPCMessage(msg) 65 } 66 67 func (r *RequestMetaHeader) MarshalJSON() ([]byte, error) { 68 return message.MarshalJSON(r) 69 } 70 71 func (r *RequestMetaHeader) UnmarshalJSON(data []byte) error { 72 msg := new(session.RequestMetaHeader) 73 74 if err := protojson.Unmarshal(data, msg); err != nil { 75 return err 76 } 77 78 return r.FromGRPCMessage(msg) 79 } 80 81 func (r *RequestVerificationHeader) MarshalJSON() ([]byte, error) { 82 return message.MarshalJSON(r) 83 } 84 85 func (r *RequestVerificationHeader) UnmarshalJSON(data []byte) error { 86 msg := new(session.RequestVerificationHeader) 87 88 if err := protojson.Unmarshal(data, msg); err != nil { 89 return err 90 } 91 92 return r.FromGRPCMessage(msg) 93 } 94 95 func (r *ResponseMetaHeader) MarshalJSON() ([]byte, error) { 96 return message.MarshalJSON(r) 97 } 98 99 func (r *ResponseMetaHeader) UnmarshalJSON(data []byte) error { 100 msg := new(session.ResponseMetaHeader) 101 102 if err := protojson.Unmarshal(data, msg); err != nil { 103 return err 104 } 105 106 return r.FromGRPCMessage(msg) 107 } 108 109 func (r *ResponseVerificationHeader) MarshalJSON() ([]byte, error) { 110 return message.MarshalJSON(r) 111 } 112 113 func (r *ResponseVerificationHeader) UnmarshalJSON(data []byte) error { 114 msg := new(session.ResponseVerificationHeader) 115 116 if err := protojson.Unmarshal(data, msg); err != nil { 117 return err 118 } 119 120 return r.FromGRPCMessage(msg) 121 } 122 123 func (x *ContainerSessionContext) MarshalJSON() ([]byte, error) { 124 return message.MarshalJSON(x) 125 } 126 127 func (x *ContainerSessionContext) UnmarshalJSON(data []byte) error { 128 return message.UnmarshalJSON(x, data, new(session.ContainerSessionContext)) 129 }