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-gobash
go get github.com/team-telnyx/telnyx-goSetup
初始化
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 is already initialized as shown above.
clientgo
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")),
)以下所有示例均假设已按上述方式完成初始化。
clientList all addresses
列出所有地址
Returns a list of your addresses.
GET /addressesgo
page, err := client.Addresses.List(context.TODO(), telnyx.AddressListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)返回您的地址列表。
GET /addressesgo
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 /addressesfirst_namelast_namebusiness_namestreet_addresslocalitycountry_codeOptional: (boolean), (string), (string), (string), (string), (string), (string), (string), (boolean)
address_bookadministrative_areaboroughcustomer_referenceextended_addressneighborhoodphone_numberpostal_codevalidate_addressgo
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 /addressesfirst_namelast_namebusiness_namestreet_addresslocalitycountry_code可选项:(布尔值), (字符串), (字符串), (字符串), (字符串), (字符串), (字符串), (字符串), (布尔值)
address_bookadministrative_areaboroughcustomer_referenceextended_addressneighborhoodphone_numberpostal_codevalidate_addressgo
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_suggestionsOptional: (string)
idgo
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可选项:(字符串)
idgo
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/validatecountry_codestreet_addresspostal_codeOptional: (string), (string), (string)
administrative_areaextended_addresslocalitygo
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/validatecountry_codestreet_addresspostal_code可选项:(字符串), (字符串), (字符串)
administrative_areaextended_addresslocalitygo
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_providersgo
page, err := client.AuthenticationProviders.List(context.TODO(), telnyx.AuthenticationProviderListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)返回您的SSO身份验证提供商列表。
GET /authentication_providersgo
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_providersnameshort_namesettingsOptional: (boolean), (uri)
activesettings_urlgo
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_providersnameshort_namesettings可选项:(布尔值), (URI)
activesettings_urlgo
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: (boolean), (string), (object), (uri), (string)
activenamesettingssettings_urlshort_namego
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}可选项:(布尔值), (字符串), (对象), (URI), (字符串)
activenamesettingssettings_urlshort_namego
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_groupsgo
page, err := client.BillingGroups.List(context.TODO(), telnyx.BillingGroupListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)GET /billing_groupsgo
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_groupsOptional: (string)
namego
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可选项:(字符串)
namego
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: (string)
namego
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}可选项:(字符串)
namego
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_secretsgo
page, err := client.IntegrationSecrets.List(context.TODO(), telnyx.IntegrationSecretListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)获取用户配置的所有集成密钥列表。
GET /integration_secretsgo
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_secretsidentifiertypeOptional: (string), (string), (string)
passwordtokenusernamego
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_secretsidentifiertype可选项:(字符串), (字符串), (字符串)
passwordtokenusernamego
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_addressgo
page, err := client.AccessIPAddress.List(context.TODO(), telnyx.AccessIPAddressListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)GET /access_ip_addressgo
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_addressip_addressOptional: (string)
descriptiongo
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_addressip_address可选项:(字符串)
descriptiongo
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_rangesgo
page, err := client.AccessIPRanges.List(context.TODO(), telnyx.AccessIPRangeListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)GET /access_ip_rangesgo
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_rangescidr_blockOptional: (string)
descriptiongo
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_rangescidr_block可选项:(字符串)
descriptiongo
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)