Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1929)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 7, 2024
1 parent 5d85f84 commit 702d17d
Show file tree
Hide file tree
Showing 4 changed files with 327 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
@@ -1,2 +1,2 @@
configured_endpoints: 1267
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6229bf7c4bed6b9026088be8817d3c8111576b2d12ff5220d193f479f230e449.yml
configured_endpoints: 1268
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7a581c61bc42c6e3e48c58c941255dca8f4b7b2e5aafd402a61c6438c2830071.yml
8 changes: 8 additions & 0 deletions api.md
Expand Up @@ -3341,6 +3341,14 @@ Methods:

## Whois

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel">intel</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#WhoisGetResponse">WhoisGetResponse</a>

Methods:

- <code title="get /accounts/{account_id}/intel/whois">client.Intel.Whois.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#WhoisService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel">intel</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#WhoisGetParams">WhoisGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel">intel</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/intel#WhoisGetResponse">WhoisGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## IndicatorFeeds

Response Types:
Expand Down
276 changes: 276 additions & 0 deletions intel/whois.go
Expand Up @@ -3,7 +3,18 @@
package intel

import (
"context"
"fmt"
"net/http"
"net/url"
"time"

"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
"github.com/cloudflare/cloudflare-go/v2/shared"
)

// WhoisService contains methods and other services that help with interacting with
Expand All @@ -22,3 +33,268 @@ func NewWhoisService(opts ...option.RequestOption) (r *WhoisService) {
r.Options = opts
return
}

// Get WHOIS Record
func (r *WhoisService) Get(ctx context.Context, params WhoisGetParams, opts ...option.RequestOption) (res *WhoisGetResponse, err error) {
opts = append(r.Options[:], opts...)
var env WhoisGetResponseEnvelope
path := fmt.Sprintf("accounts/%s/intel/whois", params.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}

type WhoisGetResponse struct {
Dnnsec interface{} `json:"dnnsec,required"`
Domain string `json:"domain,required"`
Extension string `json:"extension,required"`
Found bool `json:"found,required"`
Nameservers []string `json:"nameservers,required"`
Punycode string `json:"punycode,required"`
Registrant string `json:"registrant,required"`
Registrar string `json:"registrar,required"`
ID string `json:"id"`
AdministrativeCity string `json:"administrative_city"`
AdministrativeCountry string `json:"administrative_country"`
AdministrativeEmail string `json:"administrative_email"`
AdministrativeFax string `json:"administrative_fax"`
AdministrativeFaxExt string `json:"administrative_fax_ext"`
AdministrativeID string `json:"administrative_id"`
AdministrativeName string `json:"administrative_name"`
AdministrativeOrg string `json:"administrative_org"`
AdministrativePhone string `json:"administrative_phone"`
AdministrativePhoneExt string `json:"administrative_phone_ext"`
AdministrativePostalCode string `json:"administrative_postal_code"`
AdministrativeProvince string `json:"administrative_province"`
AdministrativeReferralURL string `json:"administrative_referral_url"`
AdministrativeStreet string `json:"administrative_street"`
BillingCity string `json:"billing_city"`
BillingCountry string `json:"billing_country"`
BillingEmail string `json:"billing_email"`
BillingFax string `json:"billing_fax"`
BillingFaxExt string `json:"billing_fax_ext"`
BillingID string `json:"billing_id"`
BillingName string `json:"billing_name"`
BillingOrg string `json:"billing_org"`
BillingPhone string `json:"billing_phone"`
BillingPhoneExt string `json:"billing_phone_ext"`
BillingPostalCode string `json:"billing_postal_code"`
BillingProvince string `json:"billing_province"`
BillingReferralURL string `json:"billing_referral_url"`
BillingStreet string `json:"billing_street"`
CreatedDate time.Time `json:"created_date" format:"date-time"`
CreatedDateRaw string `json:"created_date_raw"`
DNSSEC bool `json:"dnssec"`
ExpirationDate time.Time `json:"expiration_date" format:"date-time"`
ExpirationDateRaw string `json:"expiration_date_raw"`
RegistrantCity string `json:"registrant_city"`
RegistrantCountry string `json:"registrant_country"`
RegistrantEmail string `json:"registrant_email"`
RegistrantFax string `json:"registrant_fax"`
RegistrantFaxExt string `json:"registrant_fax_ext"`
RegistrantID string `json:"registrant_id"`
RegistrantName string `json:"registrant_name"`
RegistrantOrg string `json:"registrant_org"`
RegistrantPhone string `json:"registrant_phone"`
RegistrantPhoneExt string `json:"registrant_phone_ext"`
RegistrantPostalCode string `json:"registrant_postal_code"`
RegistrantProvince string `json:"registrant_province"`
RegistrantReferralURL string `json:"registrant_referral_url"`
RegistrantStreet string `json:"registrant_street"`
RegistrarCity string `json:"registrar_city"`
RegistrarCountry string `json:"registrar_country"`
RegistrarEmail string `json:"registrar_email"`
RegistrarFax string `json:"registrar_fax"`
RegistrarFaxExt string `json:"registrar_fax_ext"`
RegistrarID string `json:"registrar_id"`
RegistrarName string `json:"registrar_name"`
RegistrarOrg string `json:"registrar_org"`
RegistrarPhone string `json:"registrar_phone"`
RegistrarPhoneExt string `json:"registrar_phone_ext"`
RegistrarPostalCode string `json:"registrar_postal_code"`
RegistrarProvince string `json:"registrar_province"`
RegistrarReferralURL string `json:"registrar_referral_url"`
RegistrarStreet string `json:"registrar_street"`
Status []string `json:"status"`
TechnicalCity string `json:"technical_city"`
TechnicalCountry string `json:"technical_country"`
TechnicalEmail string `json:"technical_email"`
TechnicalFax string `json:"technical_fax"`
TechnicalFaxExt string `json:"technical_fax_ext"`
TechnicalID string `json:"technical_id"`
TechnicalName string `json:"technical_name"`
TechnicalOrg string `json:"technical_org"`
TechnicalPhone string `json:"technical_phone"`
TechnicalPhoneExt string `json:"technical_phone_ext"`
TechnicalPostalCode string `json:"technical_postal_code"`
TechnicalProvince string `json:"technical_province"`
TechnicalReferralURL string `json:"technical_referral_url"`
TechnicalStreet string `json:"technical_street"`
UpdatedDate time.Time `json:"updated_date" format:"date-time"`
UpdatedDateRaw string `json:"updated_date_raw"`
WhoisServer string `json:"whois_server"`
JSON whoisGetResponseJSON `json:"-"`
}

// whoisGetResponseJSON contains the JSON metadata for the struct
// [WhoisGetResponse]
type whoisGetResponseJSON struct {
Dnnsec apijson.Field
Domain apijson.Field
Extension apijson.Field
Found apijson.Field
Nameservers apijson.Field
Punycode apijson.Field
Registrant apijson.Field
Registrar apijson.Field
ID apijson.Field
AdministrativeCity apijson.Field
AdministrativeCountry apijson.Field
AdministrativeEmail apijson.Field
AdministrativeFax apijson.Field
AdministrativeFaxExt apijson.Field
AdministrativeID apijson.Field
AdministrativeName apijson.Field
AdministrativeOrg apijson.Field
AdministrativePhone apijson.Field
AdministrativePhoneExt apijson.Field
AdministrativePostalCode apijson.Field
AdministrativeProvince apijson.Field
AdministrativeReferralURL apijson.Field
AdministrativeStreet apijson.Field
BillingCity apijson.Field
BillingCountry apijson.Field
BillingEmail apijson.Field
BillingFax apijson.Field
BillingFaxExt apijson.Field
BillingID apijson.Field
BillingName apijson.Field
BillingOrg apijson.Field
BillingPhone apijson.Field
BillingPhoneExt apijson.Field
BillingPostalCode apijson.Field
BillingProvince apijson.Field
BillingReferralURL apijson.Field
BillingStreet apijson.Field
CreatedDate apijson.Field
CreatedDateRaw apijson.Field
DNSSEC apijson.Field
ExpirationDate apijson.Field
ExpirationDateRaw apijson.Field
RegistrantCity apijson.Field
RegistrantCountry apijson.Field
RegistrantEmail apijson.Field
RegistrantFax apijson.Field
RegistrantFaxExt apijson.Field
RegistrantID apijson.Field
RegistrantName apijson.Field
RegistrantOrg apijson.Field
RegistrantPhone apijson.Field
RegistrantPhoneExt apijson.Field
RegistrantPostalCode apijson.Field
RegistrantProvince apijson.Field
RegistrantReferralURL apijson.Field
RegistrantStreet apijson.Field
RegistrarCity apijson.Field
RegistrarCountry apijson.Field
RegistrarEmail apijson.Field
RegistrarFax apijson.Field
RegistrarFaxExt apijson.Field
RegistrarID apijson.Field
RegistrarName apijson.Field
RegistrarOrg apijson.Field
RegistrarPhone apijson.Field
RegistrarPhoneExt apijson.Field
RegistrarPostalCode apijson.Field
RegistrarProvince apijson.Field
RegistrarReferralURL apijson.Field
RegistrarStreet apijson.Field
Status apijson.Field
TechnicalCity apijson.Field
TechnicalCountry apijson.Field
TechnicalEmail apijson.Field
TechnicalFax apijson.Field
TechnicalFaxExt apijson.Field
TechnicalID apijson.Field
TechnicalName apijson.Field
TechnicalOrg apijson.Field
TechnicalPhone apijson.Field
TechnicalPhoneExt apijson.Field
TechnicalPostalCode apijson.Field
TechnicalProvince apijson.Field
TechnicalReferralURL apijson.Field
TechnicalStreet apijson.Field
UpdatedDate apijson.Field
UpdatedDateRaw apijson.Field
WhoisServer apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *WhoisGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r whoisGetResponseJSON) RawJSON() string {
return r.raw
}

type WhoisGetParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
Domain param.Field[string] `query:"domain"`
}

// URLQuery serializes [WhoisGetParams]'s query parameters as `url.Values`.
func (r WhoisGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}

type WhoisGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result WhoisGetResponse `json:"result,required"`
// Whether the API call was successful
Success WhoisGetResponseEnvelopeSuccess `json:"success,required"`
JSON whoisGetResponseEnvelopeJSON `json:"-"`
}

// whoisGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [WhoisGetResponseEnvelope]
type whoisGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *WhoisGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r whoisGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}

// Whether the API call was successful
type WhoisGetResponseEnvelopeSuccess bool

const (
WhoisGetResponseEnvelopeSuccessTrue WhoisGetResponseEnvelopeSuccess = true
)

func (r WhoisGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case WhoisGetResponseEnvelopeSuccessTrue:
return true
}
return false
}
41 changes: 41 additions & 0 deletions intel/whois_test.go
@@ -0,0 +1,41 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package intel_test

import (
"context"
"errors"
"os"
"testing"

"github.com/cloudflare/cloudflare-go/v2"
"github.com/cloudflare/cloudflare-go/v2/intel"
"github.com/cloudflare/cloudflare-go/v2/internal/testutil"
"github.com/cloudflare/cloudflare-go/v2/option"
)

func TestWhoisGetWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
)
_, err := client.Intel.Whois.Get(context.TODO(), intel.WhoisGetParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Domain: cloudflare.F("string"),
})
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

0 comments on commit 702d17d

Please sign in to comment.