33package addressing
44
55import (
6+ "bytes"
67 "context"
78 "errors"
89 "fmt"
10+ "mime/multipart"
911 "net/http"
1012 "slices"
13+ "time"
1114
15+ "github.com/cloudflare/cloudflare-go/v6/internal/apiform"
16+ "github.com/cloudflare/cloudflare-go/v6/internal/apijson"
1217 "github.com/cloudflare/cloudflare-go/v6/internal/param"
1318 "github.com/cloudflare/cloudflare-go/v6/internal/requestconfig"
1419 "github.com/cloudflare/cloudflare-go/v6/option"
@@ -33,6 +38,25 @@ func NewLOADocumentService(opts ...option.RequestOption) (r *LOADocumentService)
3338 return
3439}
3540
41+ // Submit LOA document (pdf format) under the account.
42+ //
43+ // Deprecated: This is API is deprecated and will be removed in a future release.
44+ func (r * LOADocumentService ) New (ctx context.Context , params LOADocumentNewParams , opts ... option.RequestOption ) (res * LOADocumentNewResponse , err error ) {
45+ var env LOADocumentNewResponseEnvelope
46+ opts = slices .Concat (r .Options , opts )
47+ if params .AccountID .Value == "" {
48+ err = errors .New ("missing required account_id parameter" )
49+ return
50+ }
51+ path := fmt .Sprintf ("accounts/%s/addressing/loa_documents" , params .AccountID )
52+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodPost , path , params , & env , opts ... )
53+ if err != nil {
54+ return
55+ }
56+ res = & env .Result
57+ return
58+ }
59+
3660// Download specified LOA document under the account.
3761func (r * LOADocumentService ) Get (ctx context.Context , loaDocumentID string , query LOADocumentGetParams , opts ... option.RequestOption ) (res * http.Response , err error ) {
3862 opts = slices .Concat (r .Options , opts )
@@ -50,6 +74,206 @@ func (r *LOADocumentService) Get(ctx context.Context, loaDocumentID string, quer
5074 return
5175}
5276
77+ type LOADocumentNewResponse struct {
78+ // Identifier for the uploaded LOA document.
79+ ID string `json:"id,nullable"`
80+ // Identifier of a Cloudflare account.
81+ AccountID string `json:"account_id"`
82+ Created time.Time `json:"created" format:"date-time"`
83+ // Name of LOA document. Max file size 10MB, and supported filetype is pdf.
84+ Filename string `json:"filename"`
85+ // File size of the uploaded LOA document.
86+ SizeBytes int64 `json:"size_bytes"`
87+ // Whether the LOA has been verified by Cloudflare staff.
88+ Verified bool `json:"verified"`
89+ // Timestamp of the moment the LOA was marked as validated.
90+ VerifiedAt time.Time `json:"verified_at,nullable" format:"date-time"`
91+ JSON loaDocumentNewResponseJSON `json:"-"`
92+ }
93+
94+ // loaDocumentNewResponseJSON contains the JSON metadata for the struct
95+ // [LOADocumentNewResponse]
96+ type loaDocumentNewResponseJSON struct {
97+ ID apijson.Field
98+ AccountID apijson.Field
99+ Created apijson.Field
100+ Filename apijson.Field
101+ SizeBytes apijson.Field
102+ Verified apijson.Field
103+ VerifiedAt apijson.Field
104+ raw string
105+ ExtraFields map [string ]apijson.Field
106+ }
107+
108+ func (r * LOADocumentNewResponse ) UnmarshalJSON (data []byte ) (err error ) {
109+ return apijson .UnmarshalRoot (data , r )
110+ }
111+
112+ func (r loaDocumentNewResponseJSON ) RawJSON () string {
113+ return r .raw
114+ }
115+
116+ type LOADocumentNewParams struct {
117+ // Identifier of a Cloudflare account.
118+ AccountID param.Field [string ] `path:"account_id,required"`
119+ // LOA document to upload.
120+ LOADocument param.Field [string ] `json:"loa_document,required"`
121+ }
122+
123+ func (r LOADocumentNewParams ) MarshalMultipart () (data []byte , contentType string , err error ) {
124+ buf := bytes .NewBuffer (nil )
125+ writer := multipart .NewWriter (buf )
126+ err = apiform .MarshalRoot (r , writer )
127+ if err != nil {
128+ writer .Close ()
129+ return nil , "" , err
130+ }
131+ err = writer .Close ()
132+ if err != nil {
133+ return nil , "" , err
134+ }
135+ return buf .Bytes (), writer .FormDataContentType (), nil
136+ }
137+
138+ type LOADocumentNewResponseEnvelope struct {
139+ Errors []LOADocumentNewResponseEnvelopeErrors `json:"errors,required"`
140+ Messages []LOADocumentNewResponseEnvelopeMessages `json:"messages,required"`
141+ // Whether the API call was successful.
142+ Success LOADocumentNewResponseEnvelopeSuccess `json:"success,required"`
143+ Result LOADocumentNewResponse `json:"result"`
144+ JSON loaDocumentNewResponseEnvelopeJSON `json:"-"`
145+ }
146+
147+ // loaDocumentNewResponseEnvelopeJSON contains the JSON metadata for the struct
148+ // [LOADocumentNewResponseEnvelope]
149+ type loaDocumentNewResponseEnvelopeJSON struct {
150+ Errors apijson.Field
151+ Messages apijson.Field
152+ Success apijson.Field
153+ Result apijson.Field
154+ raw string
155+ ExtraFields map [string ]apijson.Field
156+ }
157+
158+ func (r * LOADocumentNewResponseEnvelope ) UnmarshalJSON (data []byte ) (err error ) {
159+ return apijson .UnmarshalRoot (data , r )
160+ }
161+
162+ func (r loaDocumentNewResponseEnvelopeJSON ) RawJSON () string {
163+ return r .raw
164+ }
165+
166+ type LOADocumentNewResponseEnvelopeErrors struct {
167+ Code int64 `json:"code,required"`
168+ Message string `json:"message,required"`
169+ DocumentationURL string `json:"documentation_url"`
170+ Source LOADocumentNewResponseEnvelopeErrorsSource `json:"source"`
171+ JSON loaDocumentNewResponseEnvelopeErrorsJSON `json:"-"`
172+ }
173+
174+ // loaDocumentNewResponseEnvelopeErrorsJSON contains the JSON metadata for the
175+ // struct [LOADocumentNewResponseEnvelopeErrors]
176+ type loaDocumentNewResponseEnvelopeErrorsJSON struct {
177+ Code apijson.Field
178+ Message apijson.Field
179+ DocumentationURL apijson.Field
180+ Source apijson.Field
181+ raw string
182+ ExtraFields map [string ]apijson.Field
183+ }
184+
185+ func (r * LOADocumentNewResponseEnvelopeErrors ) UnmarshalJSON (data []byte ) (err error ) {
186+ return apijson .UnmarshalRoot (data , r )
187+ }
188+
189+ func (r loaDocumentNewResponseEnvelopeErrorsJSON ) RawJSON () string {
190+ return r .raw
191+ }
192+
193+ type LOADocumentNewResponseEnvelopeErrorsSource struct {
194+ Pointer string `json:"pointer"`
195+ JSON loaDocumentNewResponseEnvelopeErrorsSourceJSON `json:"-"`
196+ }
197+
198+ // loaDocumentNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for
199+ // the struct [LOADocumentNewResponseEnvelopeErrorsSource]
200+ type loaDocumentNewResponseEnvelopeErrorsSourceJSON struct {
201+ Pointer apijson.Field
202+ raw string
203+ ExtraFields map [string ]apijson.Field
204+ }
205+
206+ func (r * LOADocumentNewResponseEnvelopeErrorsSource ) UnmarshalJSON (data []byte ) (err error ) {
207+ return apijson .UnmarshalRoot (data , r )
208+ }
209+
210+ func (r loaDocumentNewResponseEnvelopeErrorsSourceJSON ) RawJSON () string {
211+ return r .raw
212+ }
213+
214+ type LOADocumentNewResponseEnvelopeMessages struct {
215+ Code int64 `json:"code,required"`
216+ Message string `json:"message,required"`
217+ DocumentationURL string `json:"documentation_url"`
218+ Source LOADocumentNewResponseEnvelopeMessagesSource `json:"source"`
219+ JSON loaDocumentNewResponseEnvelopeMessagesJSON `json:"-"`
220+ }
221+
222+ // loaDocumentNewResponseEnvelopeMessagesJSON contains the JSON metadata for the
223+ // struct [LOADocumentNewResponseEnvelopeMessages]
224+ type loaDocumentNewResponseEnvelopeMessagesJSON struct {
225+ Code apijson.Field
226+ Message apijson.Field
227+ DocumentationURL apijson.Field
228+ Source apijson.Field
229+ raw string
230+ ExtraFields map [string ]apijson.Field
231+ }
232+
233+ func (r * LOADocumentNewResponseEnvelopeMessages ) UnmarshalJSON (data []byte ) (err error ) {
234+ return apijson .UnmarshalRoot (data , r )
235+ }
236+
237+ func (r loaDocumentNewResponseEnvelopeMessagesJSON ) RawJSON () string {
238+ return r .raw
239+ }
240+
241+ type LOADocumentNewResponseEnvelopeMessagesSource struct {
242+ Pointer string `json:"pointer"`
243+ JSON loaDocumentNewResponseEnvelopeMessagesSourceJSON `json:"-"`
244+ }
245+
246+ // loaDocumentNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for
247+ // the struct [LOADocumentNewResponseEnvelopeMessagesSource]
248+ type loaDocumentNewResponseEnvelopeMessagesSourceJSON struct {
249+ Pointer apijson.Field
250+ raw string
251+ ExtraFields map [string ]apijson.Field
252+ }
253+
254+ func (r * LOADocumentNewResponseEnvelopeMessagesSource ) UnmarshalJSON (data []byte ) (err error ) {
255+ return apijson .UnmarshalRoot (data , r )
256+ }
257+
258+ func (r loaDocumentNewResponseEnvelopeMessagesSourceJSON ) RawJSON () string {
259+ return r .raw
260+ }
261+
262+ // Whether the API call was successful.
263+ type LOADocumentNewResponseEnvelopeSuccess bool
264+
265+ const (
266+ LOADocumentNewResponseEnvelopeSuccessTrue LOADocumentNewResponseEnvelopeSuccess = true
267+ )
268+
269+ func (r LOADocumentNewResponseEnvelopeSuccess ) IsKnown () bool {
270+ switch r {
271+ case LOADocumentNewResponseEnvelopeSuccessTrue :
272+ return true
273+ }
274+ return false
275+ }
276+
53277type LOADocumentGetParams struct {
54278 // Identifier of a Cloudflare account.
55279 AccountID param.Field [string ] `path:"account_id,required"`
0 commit comments