Skip to content

Add compliance usage endpoint and compliance host statistics #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-03-25 11:07:51.194255",
"spec_repo_commit": "20f68cb"
"regenerated": "2021-03-26 09:50:29.916648",
"spec_repo_commit": "abcc1ed"
},
"v2": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-03-25 11:08:34.265135",
"spec_repo_commit": "20f68cb"
"regenerated": "2021-03-26 09:51:13.983094",
"spec_repo_commit": "abcc1ed"
}
}
}
3 changes: 3 additions & 0 deletions docs/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Class | Method | HTTP request | Description
*UsageMeteringApi* | [**get_usage_analyzed_logs**](UsageMeteringApi.md#get_usage_analyzed_logs) | **GET** /api/v1/usage/analyzed_logs | Get hourly usage for analyzed logs
*UsageMeteringApi* | [**get_usage_attribution**](UsageMeteringApi.md#get_usage_attribution) | **GET** /api/v1/usage/attribution | Get Usage Attribution
*UsageMeteringApi* | [**get_usage_billable_summary**](UsageMeteringApi.md#get_usage_billable_summary) | **GET** /api/v1/usage/billable-summary | Get billable usage across your account
*UsageMeteringApi* | [**get_usage_compliance_monitoring**](UsageMeteringApi.md#get_usage_compliance_monitoring) | **GET** /api/v1/usage/compliance-monitoring | Get hourly usage for Compliance Monitoring
*UsageMeteringApi* | [**get_usage_fargate**](UsageMeteringApi.md#get_usage_fargate) | **GET** /api/v1/usage/fargate | Get hourly usage for Fargate
*UsageMeteringApi* | [**get_usage_hosts**](UsageMeteringApi.md#get_usage_hosts) | **GET** /api/v1/usage/hosts | Get hourly usage for hosts and containers
*UsageMeteringApi* | [**get_usage_indexed_spans**](UsageMeteringApi.md#get_usage_indexed_spans) | **GET** /api/v1/usage/indexed-spans | Get hourly usage for indexed spans
Expand Down Expand Up @@ -687,6 +688,8 @@ Class | Method | HTTP request | Description
- [UsageBillableSummaryHour](UsageBillableSummaryHour.md)
- [UsageBillableSummaryKeys](UsageBillableSummaryKeys.md)
- [UsageBillableSummaryResponse](UsageBillableSummaryResponse.md)
- [UsageComplianceHour](UsageComplianceHour.md)
- [UsageComplianceResponse](UsageComplianceResponse.md)
- [UsageCustomReportsAttributes](UsageCustomReportsAttributes.md)
- [UsageCustomReportsData](UsageCustomReportsData.md)
- [UsageCustomReportsMeta](UsageCustomReportsMeta.md)
Expand Down
14 changes: 14 additions & 0 deletions docs/v1/UsageComplianceHour.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# UsageComplianceHour

Compliance Monitoring usage for a given organization for a given hour.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**compliance_container_count** | **int** | The total number of compliance container hours from the start of the given hour's month until the given hour. | [optional]
**compliance_host_count** | **int** | The total number of compliance hosts hours from the start of the given hour's month until the given hour. | [optional]
**hour** | **datetime** | The hour for the usage. | [optional]

[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md)


12 changes: 12 additions & 0 deletions docs/v1/UsageComplianceResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# UsageComplianceResponse

The response containing the Compliance Monitoring usage for each hour for a given organization.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**usage** | [**[UsageComplianceHour]**](UsageComplianceHour.md) | Get hourly usage for Compliance Monitoring. | [optional]

[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md)


88 changes: 88 additions & 0 deletions docs/v1/UsageMeteringApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Method | HTTP request | Description
[**get_usage_analyzed_logs**](UsageMeteringApi.md#get_usage_analyzed_logs) | **GET** /api/v1/usage/analyzed_logs | Get hourly usage for analyzed logs
[**get_usage_attribution**](UsageMeteringApi.md#get_usage_attribution) | **GET** /api/v1/usage/attribution | Get Usage Attribution
[**get_usage_billable_summary**](UsageMeteringApi.md#get_usage_billable_summary) | **GET** /api/v1/usage/billable-summary | Get billable usage across your account
[**get_usage_compliance_monitoring**](UsageMeteringApi.md#get_usage_compliance_monitoring) | **GET** /api/v1/usage/compliance-monitoring | Get hourly usage for Compliance Monitoring
[**get_usage_fargate**](UsageMeteringApi.md#get_usage_fargate) | **GET** /api/v1/usage/fargate | Get hourly usage for Fargate
[**get_usage_hosts**](UsageMeteringApi.md#get_usage_hosts) | **GET** /api/v1/usage/hosts | Get hourly usage for hosts and containers
[**get_usage_indexed_spans**](UsageMeteringApi.md#get_usage_indexed_spans) | **GET** /api/v1/usage/indexed-spans | Get hourly usage for indexed spans
Expand Down Expand Up @@ -865,6 +866,93 @@ Name | Type | Description | Notes
- **Accept**: application/json;datetime-format=rfc3339


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | OK | - |
**400** | Bad Request | - |
**403** | Forbidden - User is not authorized | - |

[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)

# **get_usage_compliance_monitoring**
> UsageComplianceResponse get_usage_compliance_monitoring(start_hr)

Get hourly usage for Compliance Monitoring

Get hourly usage for Compliance Monitoring.

### Example

* Api Key Authentication (apiKeyAuth):
* Api Key Authentication (appKeyAuth):
```python
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import usage_metering_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = usage_metering_api.UsageMeteringApi(api_client)
start_hr = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour.
end_hr = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour. (optional)

# example passing only required values which don't have defaults set
try:
# Get hourly usage for Compliance Monitoring
api_response = api_instance.get_usage_compliance_monitoring(start_hr)
pprint(api_response)
except ApiException as e:
print("Exception when calling UsageMeteringApi->get_usage_compliance_monitoring: %s\n" % e)

# example passing only required values which don't have defaults set
# and optional values
try:
# Get hourly usage for Compliance Monitoring
api_response = api_instance.get_usage_compliance_monitoring(start_hr, end_hr=end_hr)
pprint(api_response)
except ApiException as e:
print("Exception when calling UsageMeteringApi->get_usage_compliance_monitoring: %s\n" % e)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**start_hr** | **datetime**| Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour. |
**end_hr** | **datetime**| Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour. | [optional]

### Return type

[**UsageComplianceResponse**](UsageComplianceResponse.md)

### Authorization

[apiKeyAuth](README.md#apiKeyAuth), [appKeyAuth](README.md#appKeyAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json;datetime-format=rfc3339


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
Expand Down
2 changes: 2 additions & 0 deletions docs/v1/UsageSummaryDate.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Name | Type | Description | Notes
**aws_lambda_invocations_sum** | **int** | Shows the sum of all AWS Lambda invocations over all hours in the current date for all organizations. | [optional]
**azure_app_service_top99p** | **int** | Shows the 99th percentile of all Azure app services over all hours in the current date for all organizations. | [optional]
**billable_ingested_bytes_sum** | **int** | Shows the sum of all log bytes ingested over all hours in the current date for all organizations. | [optional]
**compliance_container_count_sum** | **bool, date, datetime, dict, float, int, list, str, none_type** | Shows the sum of compliance containers over all hours in the current date for all organizations. | [optional]
**compliance_host_count_sum** | **int** | Shows the sum of compliance hosts over all hours in the current date for all organizations. | [optional]
**container_avg** | **int** | Shows the average of all distinct containers over all hours in the current date for all organizations. | [optional]
**container_hwm** | **int** | Shows the high-water mark of all distinct containers over all hours in the current date for all organizations. | [optional]
**custom_ts_avg** | **int** | Shows the average number of distinct custom metrics over all hours in the current date for all organizations. | [optional]
Expand Down
2 changes: 2 additions & 0 deletions docs/v1/UsageSummaryDateOrg.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Name | Type | Description | Notes
**aws_lambda_invocations_sum** | **int** | Shows the sum of all AWS Lambda invocations over all hours in the current date for the given org. | [optional]
**azure_app_service_top99p** | **int** | Shows the 99th percentile of all Azure app services over all hours in the current date for the given org. | [optional]
**billable_ingested_bytes_sum** | **int** | Shows the sum of all log bytes ingested over all hours in the current date for the given org. | [optional]
**compliance_container_agg_sum** | **bool, date, datetime, dict, float, int, list, str, none_type** | Shows the sum of all compliance containers over all hours in the current date for the given org. | [optional]
**compliance_host_agg_sum** | **int** | Shows the sum of all compliance hosts over all hours in the current date for the given org. | [optional]
**container_avg** | **int** | Shows the average of all distinct containers over all hours in the current date for the given org. | [optional]
**container_hwm** | **int** | Shows the high-water mark of all distinct containers over all hours in the current date for the given org. | [optional]
**custom_ts_avg** | **int** | Shows the average number of distinct custom metrics over all hours in the current date for the given org. | [optional]
Expand Down
2 changes: 2 additions & 0 deletions docs/v1/UsageSummaryResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Name | Type | Description | Notes
**azure_app_service_top99p_sum** | **int** | Shows the 99th percentile of all Azure app services over all hours in the current months for all organizations. | [optional]
**azure_host_top99p_sum** | **int** | Shows the 99th percentile of all Azure hosts over all hours in the current months for all organizations. | [optional]
**billable_ingested_bytes_agg_sum** | **int** | Shows the sum of all log bytes ingested over all hours in the current months for all organizations. | [optional]
**compliance_container_agg_sum** | **bool, date, datetime, dict, float, int, list, str, none_type** | Shows the sum of all compliance containers over all hours in the current months for all organizations. | [optional]
**compliance_host_agg_sum** | **int** | Shows the sum of all compliance hosts over all hours in the current months for all organizations. | [optional]
**container_avg_sum** | **int** | Shows the average of all distinct containers over all hours in the current months for all organizations. | [optional]
**container_hwm_sum** | **int** | Shows the sum of the high-water marks of all distinct containers over all hours in the current months for all organizations. | [optional]
**custom_ts_sum** | **int** | Shows the average number of distinct custom metrics over all hours in the current months for all organizations. | [optional]
Expand Down
97 changes: 97 additions & 0 deletions src/datadog_api_client/v1/api/usage_metering_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from datadog_api_client.v1.model.usage_attribution_response import UsageAttributionResponse
from datadog_api_client.v1.model.usage_attribution_sort import UsageAttributionSort
from datadog_api_client.v1.model.usage_billable_summary_response import UsageBillableSummaryResponse
from datadog_api_client.v1.model.usage_compliance_response import UsageComplianceResponse
from datadog_api_client.v1.model.usage_custom_reports_response import UsageCustomReportsResponse
from datadog_api_client.v1.model.usage_fargate_response import UsageFargateResponse
from datadog_api_client.v1.model.usage_hosts_response import UsageHostsResponse
Expand Down Expand Up @@ -1031,6 +1032,102 @@ def __get_usage_billable_summary(self, **kwargs):
callable=__get_usage_billable_summary,
)

def __get_usage_compliance_monitoring(self, start_hr, **kwargs):
"""Get hourly usage for Compliance Monitoring # noqa: E501

Get hourly usage for Compliance Monitoring. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True

>>> thread = api.get_usage_compliance_monitoring(start_hr, async_req=True)
>>> result = thread.get()

Args:
start_hr (datetime): Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour.

Keyword Args:
end_hr (datetime): Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour.. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously

Returns:
UsageComplianceResponse
If the method is called asynchronously, returns the request
thread.
"""
kwargs["async_req"] = kwargs.get("async_req", False)
kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True)
kwargs["_preload_content"] = kwargs.get("_preload_content", True)
kwargs["_request_timeout"] = kwargs.get("_request_timeout", None)
kwargs["_check_input_type"] = kwargs.get("_check_input_type", True)
kwargs["_check_return_type"] = kwargs.get("_check_return_type", True)
kwargs["_host_index"] = kwargs.get("_host_index")
kwargs["start_hr"] = start_hr
return self.call_with_http_info(**kwargs)

self.get_usage_compliance_monitoring = _Endpoint(
settings={
"response_type": (UsageComplianceResponse,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v1/usage/compliance-monitoring",
"operation_id": "get_usage_compliance_monitoring",
"http_method": "GET",
"servers": None,
},
params_map={
"all": [
"start_hr",
"end_hr",
],
"required": [
"start_hr",
],
"nullable": [],
"enum": [],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {},
"openapi_types": {
"start_hr": (datetime,),
"end_hr": (datetime,),
},
"attribute_map": {
"start_hr": "start_hr",
"end_hr": "end_hr",
},
"location_map": {
"start_hr": "query",
"end_hr": "query",
},
"collection_format_map": {},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
"content_type": [],
},
api_client=api_client,
callable=__get_usage_compliance_monitoring,
)

def __get_usage_fargate(self, start_hr, **kwargs):
"""Get hourly usage for Fargate # noqa: E501

Expand Down
Loading