telnyx-account-access-go

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 由Telnyx OpenAPI规范自动生成,请勿编辑。 -->

Telnyx Account Access - Go

Telnyx 账户访问 - Go

Installation

安装

bash
go get github.com/team-telnyx/telnyx-go
bash
go get github.com/team-telnyx/telnyx-go

Setup

初始化

go
import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)
All examples below assume
client
is already initialized as shown above.
go
import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)
以下所有示例均假设
client
已按上述方式完成初始化。

List all addresses

列出所有地址

Returns a list of your addresses.
GET /addresses
go
	page, err := client.Addresses.List(context.TODO(), telnyx.AddressListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
返回您的地址列表。
GET /addresses
go
	page, err := client.Addresses.List(context.TODO(), telnyx.AddressListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Creates an address

创建地址

Creates an address.
POST /addresses
— Required:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
Optional:
address_book
(boolean),
administrative_area
(string),
borough
(string),
customer_reference
(string),
extended_address
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
validate_address
(boolean)
go
	address, err := client.Addresses.New(context.TODO(), telnyx.AddressNewParams{
		BusinessName:  "Toy-O'Kon",
		CountryCode:   "US",
		FirstName:     "Alfred",
		LastName:      "Foster",
		Locality:      "Austin",
		StreetAddress: "600 Congress Avenue",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)
创建一个地址。
POST /addresses
— 必填项:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
可选项:
address_book
(布尔值),
administrative_area
(字符串),
borough
(字符串),
customer_reference
(字符串),
extended_address
(字符串),
neighborhood
(字符串),
phone_number
(字符串),
postal_code
(字符串),
validate_address
(布尔值)
go
	address, err := client.Addresses.New(context.TODO(), telnyx.AddressNewParams{
		BusinessName:  "Toy-O'Kon",
		CountryCode:   "US",
		FirstName:     "Alfred",
		LastName:      "Foster",
		Locality:      "Austin",
		StreetAddress: "600 Congress Avenue",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)

Retrieve an address

获取地址详情

Retrieves the details of an existing address.
GET /addresses/{id}
go
	address, err := client.Addresses.Get(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)
获取现有地址的详细信息。
GET /addresses/{id}
go
	address, err := client.Addresses.Get(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)

Deletes an address

删除地址

Deletes an existing address.
DELETE /addresses/{id}
go
	address, err := client.Addresses.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)
删除现有地址。
DELETE /addresses/{id}
go
	address, err := client.Addresses.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", address.Data)

Accepts this address suggestion as a new emergency address for Operator Connect and finishes the uploads of the numbers associated with it to Microsoft.

接受地址建议并完成号码上传

POST /addresses/{id}/actions/accept_suggestions
Optional:
id
(string)
go
	response, err := client.Addresses.Actions.AcceptSuggestions(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.AddressActionAcceptSuggestionsParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
接受该地址建议作为Operator Connect的新紧急地址,并完成关联号码到Microsoft的上传。
POST /addresses/{id}/actions/accept_suggestions
可选项:
id
(字符串)
go
	response, err := client.Addresses.Actions.AcceptSuggestions(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.AddressActionAcceptSuggestionsParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)

Validate an address

验证地址

Validates an address for emergency services.
POST /addresses/actions/validate
— Required:
country_code
,
street_address
,
postal_code
Optional:
administrative_area
(string),
extended_address
(string),
locality
(string)
go
	response, err := client.Addresses.Actions.Validate(context.TODO(), telnyx.AddressActionValidateParams{
		CountryCode:   "US",
		PostalCode:    "78701",
		StreetAddress: "600 Congress Avenue",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
验证地址是否符合紧急服务要求。
POST /addresses/actions/validate
— 必填项:
country_code
,
street_address
,
postal_code
可选项:
administrative_area
(字符串),
extended_address
(字符串),
locality
(字符串)
go
	response, err := client.Addresses.Actions.Validate(context.TODO(), telnyx.AddressActionValidateParams{
		CountryCode:   "US",
		PostalCode:    "78701",
		StreetAddress: "600 Congress Avenue",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)

List all SSO authentication providers

列出所有SSO身份验证提供商

Returns a list of your SSO authentication providers.
GET /authentication_providers
go
	page, err := client.AuthenticationProviders.List(context.TODO(), telnyx.AuthenticationProviderListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
返回您的SSO身份验证提供商列表。
GET /authentication_providers
go
	page, err := client.AuthenticationProviders.List(context.TODO(), telnyx.AuthenticationProviderListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Creates an authentication provider

创建身份验证提供商

Creates an authentication provider.
POST /authentication_providers
— Required:
name
,
short_name
,
settings
Optional:
active
(boolean),
settings_url
(uri)
go
	authenticationProvider, err := client.AuthenticationProviders.New(context.TODO(), telnyx.AuthenticationProviderNewParams{
		Name: "Okta",
		Settings: telnyx.SettingsParam{
			IdpCertFingerprint: "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
			IdpEntityID:        "https://myorg.myidp.com/saml/metadata",
			IdpSSOTargetURL:    "https://myorg.myidp.com/trust/saml2/http-post/sso",
		},
		ShortName: "myorg",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
创建一个身份验证提供商。
POST /authentication_providers
— 必填项:
name
,
short_name
,
settings
可选项:
active
(布尔值),
settings_url
(URI)
go
	authenticationProvider, err := client.AuthenticationProviders.New(context.TODO(), telnyx.AuthenticationProviderNewParams{
		Name: "Okta",
		Settings: telnyx.SettingsParam{
			IdpCertFingerprint: "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
			IdpEntityID:        "https://myorg.myidp.com/saml/metadata",
			IdpSSOTargetURL:    "https://myorg.myidp.com/trust/saml2/http-post/sso",
		},
		ShortName: "myorg",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)

Retrieve an authentication provider

获取身份验证提供商详情

Retrieves the details of an existing authentication provider.
GET /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Get(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
获取现有身份验证提供商的详细信息。
GET /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Get(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)

Update an authentication provider

更新身份验证提供商

Updates settings of an existing authentication provider.
PATCH /authentication_providers/{id}
Optional:
active
(boolean),
name
(string),
settings
(object),
settings_url
(uri),
short_name
(string)
go
	authenticationProvider, err := client.AuthenticationProviders.Update(
		context.TODO(),
		"id",
		telnyx.AuthenticationProviderUpdateParams{
			Active: telnyx.Bool(true),
			Name:   telnyx.String("Okta"),
			Settings: telnyx.SettingsParam{
				IdpEntityID:                 "https://myorg.myidp.com/saml/metadata",
				IdpSSOTargetURL:             "https://myorg.myidp.com/trust/saml2/http-post/sso",
				IdpCertFingerprint:          "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
				IdpCertFingerprintAlgorithm: telnyx.SettingsIdpCertFingerprintAlgorithmSha1,
			},
			ShortName: telnyx.String("myorg"),
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
更新现有身份验证提供商的设置。
PATCH /authentication_providers/{id}
可选项:
active
(布尔值),
name
(字符串),
settings
(对象),
settings_url
(URI),
short_name
(字符串)
go
	authenticationProvider, err := client.AuthenticationProviders.Update(
		context.TODO(),
		"id",
		telnyx.AuthenticationProviderUpdateParams{
			Active: telnyx.Bool(true),
			Name:   telnyx.String("Okta"),
			Settings: telnyx.SettingsParam{
				IdpEntityID:                 "https://myorg.myidp.com/saml/metadata",
				IdpSSOTargetURL:             "https://myorg.myidp.com/trust/saml2/http-post/sso",
				IdpCertFingerprint:          "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
				IdpCertFingerprintAlgorithm: telnyx.SettingsIdpCertFingerprintAlgorithmSha1,
			},
			ShortName: telnyx.String("myorg"),
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)

Deletes an authentication provider

删除身份验证提供商

Deletes an existing authentication provider.
DELETE /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
删除现有身份验证提供商。
DELETE /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)

List all billing groups

列出所有账单组

GET /billing_groups
go
	page, err := client.BillingGroups.List(context.TODO(), telnyx.BillingGroupListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
GET /billing_groups
go
	page, err := client.BillingGroups.List(context.TODO(), telnyx.BillingGroupListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Create a billing group

创建账单组

POST /billing_groups
Optional:
name
(string)
go
	billingGroup, err := client.BillingGroups.New(context.TODO(), telnyx.BillingGroupNewParams{
		Name: telnyx.String("string"),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)
POST /billing_groups
可选项:
name
(字符串)
go
	billingGroup, err := client.BillingGroups.New(context.TODO(), telnyx.BillingGroupNewParams{
		Name: telnyx.String("string"),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)

Get a billing group

获取账单组详情

GET /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Get(context.TODO(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)
GET /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Get(context.TODO(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)

Update a billing group

更新账单组

PATCH /billing_groups/{id}
Optional:
name
(string)
go
	billingGroup, err := client.BillingGroups.Update(
		context.TODO(),
		"f5586561-8ff0-4291-a0ac-84fe544797bd",
		telnyx.BillingGroupUpdateParams{
			Name: telnyx.String("string"),
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)
PATCH /billing_groups/{id}
可选项:
name
(字符串)
go
	billingGroup, err := client.BillingGroups.Update(
		context.TODO(),
		"f5586561-8ff0-4291-a0ac-84fe544797bd",
		telnyx.BillingGroupUpdateParams{
			Name: telnyx.String("string"),
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)

Delete a billing group

删除账单组

DELETE /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Delete(context.TODO(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)
DELETE /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Delete(context.TODO(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", billingGroup.Data)

List integration secrets

列出集成密钥

Retrieve a list of all integration secrets configured by the user.
GET /integration_secrets
go
	page, err := client.IntegrationSecrets.List(context.TODO(), telnyx.IntegrationSecretListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
获取用户配置的所有集成密钥列表。
GET /integration_secrets
go
	page, err := client.IntegrationSecrets.List(context.TODO(), telnyx.IntegrationSecretListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Create a secret

创建密钥

Create a new secret with an associated identifier that can be used to securely integrate with other services.
POST /integration_secrets
— Required:
identifier
,
type
Optional:
password
(string),
token
(string),
username
(string)
go
	integrationSecret, err := client.IntegrationSecrets.New(context.TODO(), telnyx.IntegrationSecretNewParams{
		Identifier: "my_secret",
		Type:       telnyx.IntegrationSecretNewParamsTypeBearer,
		Token:      telnyx.String("my_secret_value"),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", integrationSecret.Data)
创建一个带有关联标识符的新密钥,用于与其他服务进行安全集成。
POST /integration_secrets
— 必填项:
identifier
,
type
可选项:
password
(字符串),
token
(字符串),
username
(字符串)
go
	integrationSecret, err := client.IntegrationSecrets.New(context.TODO(), telnyx.IntegrationSecretNewParams{
		Identifier: "my_secret",
		Type:       telnyx.IntegrationSecretNewParamsTypeBearer,
		Token:      telnyx.String("my_secret_value"),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", integrationSecret.Data)

Delete an integration secret

删除集成密钥

Delete an integration secret given its ID.
DELETE /integration_secrets/{id}
go
	err := client.IntegrationSecrets.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}
根据ID删除集成密钥。
DELETE /integration_secrets/{id}
go
	err := client.IntegrationSecrets.Delete(context.TODO(), "id")
	if err != nil {
		panic(err.Error())
	}

List all Access IP Addresses

列出所有访问IP地址

GET /access_ip_address
go
	page, err := client.AccessIPAddress.List(context.TODO(), telnyx.AccessIPAddressListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
GET /access_ip_address
go
	page, err := client.AccessIPAddress.List(context.TODO(), telnyx.AccessIPAddressListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Create new Access IP Address

创建新的访问IP地址

POST /access_ip_address
— Required:
ip_address
Optional:
description
(string)
go
	accessIPAddressResponse, err := client.AccessIPAddress.New(context.TODO(), telnyx.AccessIPAddressNewParams{
		IPAddress: "ip_address",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
POST /access_ip_address
— 必填项:
ip_address
可选项:
description
(字符串)
go
	accessIPAddressResponse, err := client.AccessIPAddress.New(context.TODO(), telnyx.AccessIPAddressNewParams{
		IPAddress: "ip_address",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)

Retrieve an access IP address

获取访问IP地址详情

GET /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Get(context.TODO(), "access_ip_address_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
GET /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Get(context.TODO(), "access_ip_address_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)

Delete access IP address

删除访问IP地址

DELETE /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Delete(context.TODO(), "access_ip_address_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
DELETE /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Delete(context.TODO(), "access_ip_address_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)

List all Access IP Ranges

列出所有访问IP范围

GET /access_ip_ranges
go
	page, err := client.AccessIPRanges.List(context.TODO(), telnyx.AccessIPRangeListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
GET /access_ip_ranges
go
	page, err := client.AccessIPRanges.List(context.TODO(), telnyx.AccessIPRangeListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Create new Access IP Range

创建新的访问IP范围

POST /access_ip_ranges
— Required:
cidr_block
Optional:
description
(string)
go
	accessIPRange, err := client.AccessIPRanges.New(context.TODO(), telnyx.AccessIPRangeNewParams{
		CidrBlock: "cidr_block",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPRange.ID)
POST /access_ip_ranges
— 必填项:
cidr_block
可选项:
description
(字符串)
go
	accessIPRange, err := client.AccessIPRanges.New(context.TODO(), telnyx.AccessIPRangeNewParams{
		CidrBlock: "cidr_block",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPRange.ID)

Delete access IP ranges

删除访问IP范围

DELETE /access_ip_ranges/{access_ip_range_id}
go
	accessIPRange, err := client.AccessIPRanges.Delete(context.TODO(), "access_ip_range_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPRange.ID)
DELETE /access_ip_ranges/{access_ip_range_id}
go
	accessIPRange, err := client.AccessIPRanges.Delete(context.TODO(), "access_ip_range_id")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accessIPRange.ID)