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