addApiTokenByAdminId
add api tokens for a user
/setting/admins/{adminId}/apitokens
Usage and SDK Samples
curl -X POST\
-H "Authorization: [[apiKey]]"\
-H "Accept: application/json"\
-H "Content-Type: application/json"\
"/santaba/rest/setting/admins/{adminId}/apitokens?type="
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.APITokensApi;
import java.io.File;
import java.util.*;
public class APITokensApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: LMv1
ApiKeyAuth LMv1 = (ApiKeyAuth) defaultClient.getAuthentication("LMv1");
LMv1.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//LMv1.setApiKeyPrefix("Token");
APITokensApi apiInstance = new APITokensApi();
Integer adminId = 56; // Integer |
APIToken body = ; // APIToken |
String type = type_example; // String |
try {
APIToken result = apiInstance.addApiTokenByAdminId(adminId, body, type);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling APITokensApi#addApiTokenByAdminId");
e.printStackTrace();
}
}
}
import io.swagger.client.api.APITokensApi;
public class APITokensApiExample {
public static void main(String[] args) {
APITokensApi apiInstance = new APITokensApi();
Integer adminId = 56; // Integer |
APIToken body = ; // APIToken |
String type = type_example; // String |
try {
APIToken result = apiInstance.addApiTokenByAdminId(adminId, body, type);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling APITokensApi#addApiTokenByAdminId");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure API key authorization: (authentication scheme: LMv1)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"Authorization"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"Authorization"];
Integer *adminId = 56; //
APIToken *body = ; //
String *type = type_example; // (optional) (default to API Token)
APITokensApi *apiInstance = [[APITokensApi alloc] init];
// add api tokens for a user
[apiInstance addApiTokenByAdminIdWith
adminId:adminId:body
type:type
completionHandler: ^(APIToken output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var LogicMonitorRestApi = require('logic_monitor_rest_api');
var defaultClient = LogicMonitorRestApi.ApiClient.instance;
// Configure API key authorization: LMv1
var LMv1 = defaultClient.authentications['LMv1'];
LMv1.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//LMv1.apiKeyPrefix['Authorization'] = "Token"
var api = new LogicMonitorRestApi.APITokensApi()
var adminId = 56; // {{Integer}}
var body = ; // {{APIToken}}
var opts = {
'type': type_example // {{String}}
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.addApiTokenByAdminId(adminIdbody, opts, callback);
using System;
using System.Diagnostics;
using logicmonitor_sdk.Api;
using logicmonitor_sdk.Client;
using logicmonitor_sdk.Model;
namespace Example
{
public class addApiTokenByAdminIdExample
{
public void main()
{
// Configure API key authorization: LMv1
Configuration.Default.ApiKey.Add("Authorization", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer");
var apiInstance = new APITokensApi();
var adminId = 56; // Integer |
var body = new APIToken(); // APIToken |
var type = type_example; // String | (optional) (default to API Token)
try
{
// add api tokens for a user
APIToken result = apiInstance.addApiTokenByAdminId(adminId, body, type);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling APITokensApi.addApiTokenByAdminId: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: LMv1
Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer');
$api_instance = new Swagger\Client\ApiAPITokensApi();
$adminId = 56; // Integer |
$body = ; // APIToken |
$type = type_example; // String |
try {
$result = $api_instance->addApiTokenByAdminId($adminId, $body, $type);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling APITokensApi->addApiTokenByAdminId: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::APITokensApi;
# Configure API key authorization: LMv1
$WWW::SwaggerClient::Configuration::api_key->{'Authorization'} = 'YOUR_API_KEY';
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$WWW::SwaggerClient::Configuration::api_key_prefix->{'Authorization'} = "Bearer";
my $api_instance = WWW::SwaggerClient::APITokensApi->new();
my $adminId = 56; # Integer |
my $body = WWW::SwaggerClient::Object::APIToken->new(); # APIToken |
my $type = type_example; # String |
eval {
my $result = $api_instance->addApiTokenByAdminId(adminId => $adminId, body => $body, type => $type);
print Dumper($result);
};
if ($@) {
warn "Exception when calling APITokensApi->addApiTokenByAdminId: $@\n";
}
from __future__ import print_function
import time
import getpass
import logicmonitor_sdk
from logicmonitor_sdk.rest import ApiException
from pprint import pprint
configuration = logicmonitor_sdk.Configuration()
# Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
# Note: The below is provided for illustration purposes only.
# Configure API key authorization: LMv1
configuration.company = 'YOUR_COMPANY'
configuration.access_id = getpass.getpass("Enter your AccessId: ")
configuration.access_key = getpass.getpass("Enter your AccessKey: ")
# Configure API key authorization: Bearer configuration. In case of bearer token remove the above access_key and access_id assignments as they are LMv1 specific
# configuration.auth_type = "Bearer"
# configuration.bearer_token = getpass.getpass("Enter your Bearer Token: ")
# create an instance of the API class test2
api_instance = logicmonitor_sdk.LMApi(logicmonitor_sdk.ApiClient(configuration))
try:
# add api tokens for a user
api_response = api_instance.add_api_token_by_admin_id(adminId, body, type=type)
print(api_response)
except ApiException as e:
print("Exception when calling APITokensApi->addApiTokenByAdminId: %s\n" % e)
package main
import (
"fmt"
"strings"
"syscall"
"golang.org/x/term"
"github.com/logicmonitor/lm-sdk-go/client"
"github.com/logicmonitor/lm-sdk-go/client/lm"
"github.com/logicmonitor/lm-sdk-go/models"
)
func main() {
// Configure API key authorization: LMv1
domain := "YOUR_COMPANY.logicmonitor.com"
// Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
// Note: The below is provided for illustration purposes only.
// Configure API key authorization: LMv1
fmt.Println("\nEnter AccessID: ")
byteAccessID, err := term.ReadPassword(int(syscall.Stdin))
if err != nil {
return
}
accessID := strings.TrimSpace(string(byteAccessID))
fmt.Println("\nEnter AccessKey: ")
byteAccessKey, err := term.ReadPassword(int(syscall.Stdin))
if err != nil {
return
}
accessKey := strings.TrimSpace(string(byteAccessKey))
// Configure API key authorization: Bearer configuration. In case of bearer token remove the above access_key and access_id assignments as they are LMv1 specific
// fmt.Println("\nEnter Bearer Token: ")
// byteBearer, err := term.ReadPassword(int(syscall.Stdin))
// if err != nil {
// return
// }
// bearer := strings.TrimSpace(string(byteBearer))
config := client.NewConfig()
config.SetAccountDomain(&domain)
config.SetAccessID(&accessID)
config.SetAccessKey(&accessKey)
// config.SetBearerToken(&bearer)
// create an instance of the API class
client := client.New(config)
params := lm.NewAddApiTokenByAdminIdParams()
// add api tokens for a user
// This method returns the all fields irrespective of 'fields' param.
resp, err := client.LM.AddApiTokenByAdminId(params)
if err != nil {
fmt.Printf("Exception when calling client.LM.AddApiTokenByAdminId: %v", err.Error())
}
fmt.Print(resp)
}
Parameters
Path parameters
Name | Description |
---|---|
adminId* |
Integer
(int32)
Required
|
Body parameters
Name | Description |
---|---|
body * |
Query parameters
Name | Description |
---|---|
type |
String
|