openapi

package
v4.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 6 Imported by: 0

README

Go API client for

The Twilio SendGrid API Keys API allows you manage your API keys and their settings. Your application, mail client, or website can all use API keys to authenticate access to SendGrid services.

To create your initial SendGrid API Key, you should use the SendGrid application user interface. Once you have created a first key with scopes to manage additional API keys, you can use this API for all other key management.

Overview

This API client was generated by the OpenAPI Generator project from the OpenAPI specs located at twilio/sendgrid-oai. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version:
  • Build date: 2024-10-24T13:26:01.855307Z[Etc/UTC]
  • Build package: com.sendgrid.oai.go.SendgridGoGenerator For more information, please visit https://support.sendgrid.com/hc/en-us

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import "./"

Documentation for API Endpoints

All URIs are relative to https://api.sendgrid.com

Class Method HTTP request Description
CreateApiKey CreateApiKey Post /v3/api_keys Create API keys
DeleteApiKey DeleteApiKey Delete /v3/api_keys/{ApiKeyId} Delete API keys
GetApiKey GetApiKey Get /v3/api_keys/{ApiKeyId} Retrieve an existing API Key
ListApiKey ListApiKey Get /v3/api_keys Retrieve all API Keys belonging to the authenticated user
UpdateApiKey UpdateApiKey Put /v3/api_keys/{ApiKeyId} Update API key name and scopes
UpdateApiKeyName UpdateApiKeyName Patch /v3/api_keys/{ApiKeyId} Update API key name

Documentation For Models

Documentation For Authorization

BearerAuth

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
    UserName: "username",
    Password: "password",
})
r, err := client.Service.Operation(auth, args)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKeyResponse

type ApiKeyResponse struct {
	// The ID of your API Key.
	ApiKeyId *string `json:"api_key_id,omitempty"`
	// The name of your API Key.
	Name *string `json:"name,omitempty"`
}

ApiKeyResponse struct for ApiKeyResponse

type ApiKeyScopesResponse

type ApiKeyScopesResponse struct {
	// The permissions this API Key has access to.
	Scopes *[]string `json:"scopes,omitempty"`
	// The ID of your API Key.
	ApiKeyId *string `json:"api_key_id,omitempty"`
	// The name of your API Key.
	Name *string `json:"name,omitempty"`
}

ApiKeyScopesResponse struct for ApiKeyScopesResponse

type ApiService

type ApiService struct {
	// contains filtered or unexported fields
}

func NewApiService

func NewApiService(requestHandler *sendgrid.RequestHandler) *ApiService

func NewApiServiceWithClient

func NewApiServiceWithClient(client sendgrid.BaseClient) *ApiService

func (*ApiService) CreateApiKey

func (c *ApiService) CreateApiKey(params *CreateApiKeyParam) (interface{}, error)

**This endpoint allows you to create a new API Key for the user.** To create your initial SendGrid API Key, you should [use the SendGrid App](https://app.sendgrid.com/settings/api_keys). Once you have created a first key with scopes to manage additional API keys, you can use this API for all other key management. A JSON request body containing a `name` property is required when making requests to this endpoint. If the number of maximum keys, 100, is reached, a `403` status will be returned. Though the `name` field is required, it does not need to be unique. A unique API key ID will be generated for each key you create and returned in the response body. It is not necessary to pass a `scopes` field to the API when creating a key, but you should be aware that omitting the `scopes` field from your request will create a key with \"Full Access\" permissions by default. See the [API Key Permissions List](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authorization) for all available scopes. An API key's scopes can be updated after creation using the \"Update API keys\" endpoint.

func (*ApiService) DeleteApiKey

func (c *ApiService) DeleteApiKey(params *DeleteApiKeyParam) (interface{}, error)

**This endpoint allows you to revoke an existing API Key using an `api_key_id`** Authentications using a revoked API Key will fail after after some small propogation delay. If the API Key ID does not exist, a `404` status will be returned.

func (*ApiService) GetApiKey

func (c *ApiService) GetApiKey(params *GetApiKeyParam) (interface{}, error)

**This endpoint allows you to retrieve a single API key using an `api_key_id`.** The endpoint will return a key's name, ID, and scopes. If the API Key ID does not, exist a `404` status will be returned. See the [API Key Permissions List](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authorization) for all available scopes. An API key's scopes can be updated after creation using the \"Update API keys\" endpoint.

func (*ApiService) ListApiKey

func (c *ApiService) ListApiKey(params *ListApiKeyParam) (interface{}, error)

**This endpoint allows you to retrieve all API Keys that belong to the authenticated user.** A successful response from this API will include all available API keys' names and IDs. For security reasons, there is not a way to retrieve the key itself after it's created. If you lose your API key, you must create a new one. Only the \"Create API keys\" endpoint will return a key to you and only at the time of creation. An `api_key_id` can be used to update or delete the key, as well as retrieve the key's details, such as its scopes.

func (*ApiService) UpdateApiKey

func (c *ApiService) UpdateApiKey(params *UpdateApiKeyParam) (interface{}, error)

**This endpoint allows you to update the name and scopes of a given API key.** You must pass this endpoint a JSON request body with a `name` field and a `scopes` array containing at least one scope. The `name` and `scopes` fields will be used to update the key associated with the `api_key_id` in the request URL. If you need to update a key's scopes only, pass the `name` field with the key's existing name; the `name` will not be modified. If you need to update a key's name only, use the \"Update API key name\" endpoint. See the [API Key Permissions List](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authorization) for all available scopes.

func (*ApiService) UpdateApiKeyName

func (c *ApiService) UpdateApiKeyName(params *UpdateApiKeyNameParam) (interface{}, error)

**This endpoint allows you to update the name of an existing API Key.** You must pass this endpoint a JSON request body with a `name` property, which will be used to rename the key associated with the `api_key_id` passed in the URL.

type CreateApiKey201Response

type CreateApiKey201Response struct {
	ApiKey   *string   `json:"api_key,omitempty"`
	ApiKeyId *string   `json:"api_key_id,omitempty"`
	Name     *string   `json:"name,omitempty"`
	Scopes   *[]string `json:"scopes,omitempty"`
}

CreateApiKey201Response struct for CreateApiKey201Response

type CreateApiKeyParam

type CreateApiKeyParam struct {
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
	//
	CreateApiKeyRequest *CreateApiKeyRequest `json:"CreateApiKeyRequest,omitempty"`
}

func (*CreateApiKeyParam) SetCreateApiKeyRequest

func (params *CreateApiKeyParam) SetCreateApiKeyRequest(CreateApiKeyRequest CreateApiKeyRequest) *CreateApiKeyParam

func (*CreateApiKeyParam) SetOnbehalfof

func (params *CreateApiKeyParam) SetOnbehalfof(Onbehalfof string) *CreateApiKeyParam

type CreateApiKeyRequest

type CreateApiKeyRequest struct {
	// The name you will use to describe this API Key.
	Name string `json:"name"`
	// The individual permissions that you are giving to this API Key.
	Scopes *[]string `json:"scopes,omitempty"`
}

CreateApiKeyRequest struct for CreateApiKeyRequest

type DeleteApiKeyParam

type DeleteApiKeyParam struct {
	//
	ApiKeyId *string `json:"api_key_id"`
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
}

func (*DeleteApiKeyParam) SetApiKeyId

func (params *DeleteApiKeyParam) SetApiKeyId(ApiKeyId string) *DeleteApiKeyParam

func (*DeleteApiKeyParam) SetOnbehalfof

func (params *DeleteApiKeyParam) SetOnbehalfof(Onbehalfof string) *DeleteApiKeyParam

type ErrorResponse

type ErrorResponse struct {
	Errors *[]ErrorResponseErrorsInner `json:"errors,omitempty"`
	// When applicable, this property value will be an error ID.
	Id *string `json:"id,omitempty"`
}

ErrorResponse struct for ErrorResponse

type ErrorResponseErrorsInner

type ErrorResponseErrorsInner struct {
	// An error message.
	Message *string `json:"message,omitempty"`
	// When applicable, this property value will be the field that generated the error.
	Field *string `json:"field,omitempty"`
	// When applicable, this property value will be helper text or a link to documentation to help you troubleshoot the error.
	Help *map[string]interface{} `json:"help,omitempty"`
}

ErrorResponseErrorsInner struct for ErrorResponseErrorsInner

type GetApiKey200Response

type GetApiKey200Response struct {
	Result *[]ApiKeyScopesResponse `json:"result,omitempty"`
}

GetApiKey200Response struct for GetApiKey200Response

type GetApiKeyParam

type GetApiKeyParam struct {
	//
	ApiKeyId *string `json:"api_key_id"`
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
}

func (*GetApiKeyParam) SetApiKeyId

func (params *GetApiKeyParam) SetApiKeyId(ApiKeyId string) *GetApiKeyParam

func (*GetApiKeyParam) SetOnbehalfof

func (params *GetApiKeyParam) SetOnbehalfof(Onbehalfof string) *GetApiKeyParam

type ListApiKey200Response

type ListApiKey200Response struct {
	Result *[]ApiKeyResponse `json:"result,omitempty"`
}

ListApiKey200Response struct for ListApiKey200Response

type ListApiKeyParam

type ListApiKeyParam struct {
	//
	Limit *int32 `json:"limit,omitempty"`
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
}

func (*ListApiKeyParam) SetLimit

func (params *ListApiKeyParam) SetLimit(Limit int32) *ListApiKeyParam

func (*ListApiKeyParam) SetOnbehalfof

func (params *ListApiKeyParam) SetOnbehalfof(Onbehalfof string) *ListApiKeyParam

type UpdateApiKeyNameParam

type UpdateApiKeyNameParam struct {
	//
	ApiKeyId *string `json:"api_key_id"`
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
	//
	UpdateApiKeyNameRequest *UpdateApiKeyNameRequest `json:"UpdateApiKeyNameRequest,omitempty"`
}

func (*UpdateApiKeyNameParam) SetApiKeyId

func (params *UpdateApiKeyNameParam) SetApiKeyId(ApiKeyId string) *UpdateApiKeyNameParam

func (*UpdateApiKeyNameParam) SetOnbehalfof

func (params *UpdateApiKeyNameParam) SetOnbehalfof(Onbehalfof string) *UpdateApiKeyNameParam

func (*UpdateApiKeyNameParam) SetUpdateApiKeyNameRequest

func (params *UpdateApiKeyNameParam) SetUpdateApiKeyNameRequest(UpdateApiKeyNameRequest UpdateApiKeyNameRequest) *UpdateApiKeyNameParam

type UpdateApiKeyNameRequest

type UpdateApiKeyNameRequest struct {
	// The new name of the API Key.
	Name string `json:"name"`
}

UpdateApiKeyNameRequest struct for UpdateApiKeyNameRequest

type UpdateApiKeyParam

type UpdateApiKeyParam struct {
	//
	ApiKeyId *string `json:"api_key_id"`
	// The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.
	Onbehalfof *string `json:"on-behalf-of,omitempty"`
	//
	UpdateApiKeyRequest *UpdateApiKeyRequest `json:"UpdateApiKeyRequest,omitempty"`
}

func (*UpdateApiKeyParam) SetApiKeyId

func (params *UpdateApiKeyParam) SetApiKeyId(ApiKeyId string) *UpdateApiKeyParam

func (*UpdateApiKeyParam) SetOnbehalfof

func (params *UpdateApiKeyParam) SetOnbehalfof(Onbehalfof string) *UpdateApiKeyParam

func (*UpdateApiKeyParam) SetUpdateApiKeyRequest

func (params *UpdateApiKeyParam) SetUpdateApiKeyRequest(UpdateApiKeyRequest UpdateApiKeyRequest) *UpdateApiKeyParam

type UpdateApiKeyRequest

type UpdateApiKeyRequest struct {
	Name   string    `json:"name"`
	Scopes *[]string `json:"scopes,omitempty"`
}

UpdateApiKeyRequest struct for UpdateApiKeyRequest

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL