com.logicmonitor.logs.LMLogsApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lm-logs-sdk-java Show documentation
Show all versions of lm-logs-sdk-java Show documentation
Sends logs to LogicMonitor log ingestion endpoint.
/*
* Copyright (C) 2020 LogicMonitor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.logicmonitor.logs;
import java.util.List;
import com.logicmonitor.logs.api.LogIngestApi;
import com.logicmonitor.logs.invoker.ApiException;
import com.logicmonitor.logs.invoker.ApiResponse;
import com.logicmonitor.logs.model.LogEntry;
import com.logicmonitor.logs.model.LogResponse;
/**
* Implementation of LogicMonitor Logs API.
*/
public class LMLogsApi extends LogIngestApi {
/**
* API version.
*/
public static final Integer API_VERSION = 2;
/**
* Name of the response header containing request ID.
*/
public static final String REQUEST_ID_HEADER = "X-Request-ID";
/**
* Initializes LMLogsClient instance with the default company name.
* @param accessId LogicMonitor access ID.
* @param accessKey LogicMonitor access key.
* @throws NullPointerException if any of the parameters is null.
*/
public LMLogsApi(String accessId, String accessKey) {
super(new LMLogsClient(accessId, accessKey));
}
/**
* Initializes LMLogsClient instance.
* @param company company name.
* @param accessId LogicMonitor access ID.
* @param accessKey LogicMonitor access key.
* @throws NullPointerException when accessId or accessKey is null.
*/
public LMLogsApi(String company, String accessId, String accessKey) {
this(accessId, accessKey);
getApiClient().setCompany(company);
}
/**
* Gets the LogicMonitor Logs client instance.
* @return LogIngestApi.
*/
@Override
public LMLogsClient getApiClient() {
return (LMLogsClient) super.getApiClient();
}
/**
* Send custom logs to your LogicMonitor account.
* @param logEntry (required)
* @return LogResponse
* @throws ApiException if fails to make API call
* @http.response.details
Response Details
Status Code Description Response Headers
202 The request has been accepted for processing, but the processing has not been completed. * X-Request-ID -
401 TAuthentication failed. The API key provided in not valid. * X-Request-ID -
402 The account is not registered as a customer. * X-Request-ID -
403 The API key doesn’t have permissions to perform the request. * X-Request-ID -
413 The maximum content size per payload is 8 MB. * X-Request-ID -
422 The request cannot be processed. * X-Request-ID -
429 The number of requests exceeds the rate limit. * X-Request-ID -
500 Something went wrong on LogicMonitor’s end. * X-Request-ID -
*/
public LogResponse logIngestPost(List logEntry) throws ApiException {
return super.logIngestPost(API_VERSION, logEntry);
}
/**
* Send custom logs to your LogicMonitor account.
* @param logEntry (required)
* @return ApiResponse<LogResponse>
* @throws ApiException if fails to make API call
* @http.response.details
Response Details
Status Code Description Response Headers
202 The request has been accepted for processing, but the processing has not been completed. * X-Request-ID -
401 TAuthentication failed. The API key provided in not valid. * X-Request-ID -
402 The account is not registered as a customer. * X-Request-ID -
403 The API key doesn’t have permissions to perform the request. * X-Request-ID -
413 The maximum content size per payload is 8 MB. * X-Request-ID -
422 The request cannot be processed. * X-Request-ID -
429 The number of requests exceeds the rate limit. * X-Request-ID -
500 Something went wrong on LogicMonitor’s end. * X-Request-ID -
*/
public ApiResponse logIngestPostWithHttpInfo(List logEntry)
throws ApiException {
return super.logIngestPostWithHttpInfo(API_VERSION, logEntry);
}
}