Base URL: https://api.emma.ms/external
This Infrastructure API is for managing the cloud infrastructure within a project.
To access the API, enter your project, navigate to Settings > Service Apps, and create a service application. Select the access level Read, Operate, or Manage.
After creating the service application, copy the Client ID and Client Secret. Send an API request to the endpoint _/issue-token as specified in the Authentication section of the API documentation. You will receive access and refresh tokens in the response.
The Bearer access token is a text string, included in the request header, example:
-H Authorization: Bearer {token}
Use this token for API requests. The access token will expire in 10 minutes. A new access token may be created using the refresh token (without Client ID and Client Secret).
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 0.0.1
- Package version: 0.0.1
- Generator version: 7.5.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
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 emma "github.com/emma-community/emma-go-sdk"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value emma.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), emma.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value emma.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), emma.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using emma.ContextOperationServerIndices
and emma.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), emma.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), emma.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to https://api.emma.ms/external
Class | Method | HTTP request | Description |
---|---|---|---|
AuthenticationAPI | IssueToken | Post /v1/issue-token | Issue token |
AuthenticationAPI | RefreshToken | Post /v1/refresh-token | Refresh token |
ComputeInstancesConfigurationsAPI | GetSpotConfigs | Get /v1/spots-configs | Search available configurations for spot instance creation |
ComputeInstancesConfigurationsAPI | GetVmConfigs | Get /v1/vms-configs | Search available configurations for virtual machine creation |
DataCentersAPI | GetDataCenter | Get /v1/data-centers/{dataCenterId} | Get data center by ID |
DataCentersAPI | GetDataCenters | Get /v1/data-centers | Get list of data centers |
LocationsAPI | GetLocation | Get /v1/locations/{locationId} | Get location by ID |
LocationsAPI | GetLocations | Get /v1/locations | Get list of locations |
OperatingSystemsAPI | GetOperatingSystem | Get /v1/operating-systems/{operatingSystemId} | Get operating system by ID |
OperatingSystemsAPI | GetOperatingSystems | Get /v1/operating-systems | Get list of operating systems |
ProvidersAPI | GetProvider | Get /v1/providers/{providerId} | Get cloud provider by ID |
ProvidersAPI | GetProviders | Get /v1/providers | Get list of cloud providers |
SSHKeysAPI | GetSshKey | Get /v1/ssh-keys/{sshKeyId} | Get SSH key by id |
SSHKeysAPI | SshKeyDelete | Delete /v1/ssh-keys/{sshKeyId} | Delete SSH keys |
SSHKeysAPI | SshKeyUpdate | Put /v1/ssh-keys/{sshKeyId} | Update SSH keys |
SSHKeysAPI | SshKeys | Get /v1/ssh-keys | Get list of SSH keys |
SSHKeysAPI | SshKeysCreateImport | Post /v1/ssh-keys | Create or import SSH key |
SecurityGroupsAPI | GetSecurityGroup | Get /v1/security-groups/{securityGroupId} | Get security group by ID |
SecurityGroupsAPI | GetSecurityGroups | Get /v1/security-groups | Get list of security groups |
SecurityGroupsAPI | SecurityGroupCreate | Post /v1/security-groups | Create security group |
SecurityGroupsAPI | SecurityGroupDelete | Delete /v1/security-groups/{securityGroupId} | Delete security group |
SecurityGroupsAPI | SecurityGroupInstanceAdd | Post /v1/security-groups/{securityGroupId}/instances | Add instance to security group |
SecurityGroupsAPI | SecurityGroupInstances | Get /v1/security-groups/{securityGroupId}/instances | Get instances in security group |
SecurityGroupsAPI | SecurityGroupUpdate | Put /v1/security-groups/{securityGroupId} | Update security group |
SpotInstancesAPI | GetSpot | Get /v1/spot-instances/{spotInstanceId} | Get spot instance by id |
SpotInstancesAPI | GetSpots | Get /v1/spot-instances | Get list of spot instances |
SpotInstancesAPI | SpotActions | Post /v1/spot-instances/{spotInstanceId}/actions | Perform actions with a spot instance |
SpotInstancesAPI | SpotCreate | Post /v1/spot-instances | Create spot instance |
SpotInstancesAPI | SpotDelete | Delete /v1/spot-instances/{spotInstanceId} | Delete spot instance |
VirtualMachinesAPI | GetVm | Get /v1/vms/{vmId} | Get virtual machine by id |
VirtualMachinesAPI | GetVms | Get /v1/vms | Get list of virtual machines |
VirtualMachinesAPI | VmActions | Post /v1/vms/{vmId}/actions | Perform actions with a virtual machine |
VirtualMachinesAPI | VmCreate | Post /v1/vms | Create virtual machine |
VirtualMachinesAPI | VmDelete | Delete /v1/vms/{vmId} | Delete virtual machine |
- BadRequestError
- ConflictError
- Credentials
- DataCenter
- ForbiddenError
- GetVmConfigs200Response
- Location
- NotFoundError
- OperatingSystem
- PageableObject
- PaginatedResult
- Provider
- RefreshToken
- SecurityGroup
- SecurityGroupInstanceAdd
- SecurityGroupRequest
- SecurityGroupRule
- SecurityGroupRuleRequest
- SortObject
- SpotActionsRequest
- SpotCreate
- SpotReboot
- SshKey
- SshKeyCreate
- SshKeyGenerated
- SshKeyImport
- SshKeyUpdate
- SshKeysCreateImport201Response
- SshKeysCreateImportRequest
- Token
- UnauthorizedError
- UnprocessableEntityError
- Vm
- VmActionsRequest
- VmClone
- VmConfiguration
- VmConfigurationCost
- VmCost
- VmCreate
- VmDataCenter
- VmDisksInner
- VmEditHardware
- VmLocation
- VmNetworksInner
- VmOs
- VmProvider
- VmReboot
- VmSecurityGroup
- VmShutdown
- VmStart
- VmTransfer
Authentication schemes defined for the API:
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), emma.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime