Skip to content
Closed
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
80 changes: 80 additions & 0 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Method | HTTP request | Description
[**get_notification_history**](DefaultApi.md#get_notification_history) | **POST** /notifications/{notification_id}/history | Notification History
[**get_notifications**](DefaultApi.md#get_notifications) | **GET** /notifications | View notifications
[**get_outcomes**](DefaultApi.md#get_outcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes
[**get_segment**](DefaultApi.md#get_segment) | **GET** /apps/{app_id}/segments/{segment_id} | View Segment
[**get_segments**](DefaultApi.md#get_segments) | **GET** /apps/{app_id}/segments | Get Segments
[**get_user**](DefaultApi.md#get_user) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
[**rotate_api_key**](DefaultApi.md#rotate_api_key) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key
Expand Down Expand Up @@ -2609,6 +2610,85 @@ Name | Type | Description | Notes

[[Back to top]](#) [[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)

# **get_segment**
> GetSegmentSuccessResponse get_segment(app_id, segment_id)

View Segment

Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters.

### Example

* Bearer Authentication (rest_api_key):

```python
import onesignal
from onesignal.api import default_api
from onesignal.models import *
from pprint import pprint

# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_API_KEY" # Organization key is only required for creating new apps and other top-level endpoints
)


# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
app_id = "YOUR_APP_ID" # The OneSignal App ID for your app. Available in Keys & IDs.
segment_id = "d6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e" # The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.
include_segment_detail = True # Set to true to include segment metadata and filters in the response. (optional)

try:
# View Segment
api_response = api_instance.get_segment(app_id, segment_id, include_segment_detail=include_segment_detail)
pprint(api_response)
except onesignal.ApiException as e:
print("Exception when calling DefaultApi->get_segment: %s\n" % e)
print("Status Code: %s" % e.status)
print("Response Body: %s" % e.body)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**app_id** | **str**| The OneSignal App ID for your app. Available in Keys & IDs. |
**segment_id** | **str**| The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. |
**include_segment_detail** | **bool**| Set to true to include segment metadata and filters in the response. | [optional]

### Return type

[**GetSegmentSuccessResponse**](GetSegmentSuccessResponse.md)

### Authorization

[rest_api_key](https://github.com/OneSignal/onesignal-python-api#configuration)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json


### HTTP response details

| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | OK | - |
**400** | Bad Request | - |
**404** | Not Found | - |
**429** | Rate Limit Exceeded | - |
**0** | Unexpected error | - |

[[Back to top]](#) [[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)

# **get_segments**
> GetSegmentsSuccessResponse get_segments(app_id)

Expand Down
13 changes: 13 additions & 0 deletions docs/GetSegmentSuccessResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# GetSegmentSuccessResponse


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**subscriber_count** | **int** | The number of subscribers matching this segment. | [optional]
**payload** | [**SegmentDetails**](SegmentDetails.md) | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


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

Segment details. Only included when the include-segment-detail query parameter is set to true.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | The unique identifier for the segment (UUID v4). | [optional]
**name** | **str** | The segment name. | [optional]
**description** | **str, none_type** | Human-readable description for the segment. `null` when unset. Maximum 255 characters. | [optional]
**created_at** | **int** | Unix timestamp when the segment was created. | [optional]
**source** | **str** | The source of the segment. | [optional]
**filters** | [**[FilterExpression]**](FilterExpression.md) | Array of filter and operator objects defining the segment criteria. Uses the same format as the Create Segment API, so filters can be directly used to recreate or update the segment. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


151 changes: 151 additions & 0 deletions onesignal/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from onesignal.model.generic_error import GenericError
from onesignal.model.generic_success_bool_response import GenericSuccessBoolResponse
from onesignal.model.get_notification_history_request_body import GetNotificationHistoryRequestBody
from onesignal.model.get_segment_success_response import GetSegmentSuccessResponse
from onesignal.model.get_segments_success_response import GetSegmentsSuccessResponse
from onesignal.model.notification import Notification
from onesignal.model.notification_history_success_response import NotificationHistorySuccessResponse
Expand Down Expand Up @@ -1746,6 +1747,68 @@ def __init__(self, api_client=None):
},
api_client=api_client
)
self.get_segment_endpoint = _Endpoint(
settings={
'response_type': (GetSegmentSuccessResponse,),
'auth': [
'rest_api_key'
],
'endpoint_path': '/apps/{app_id}/segments/{segment_id}',
'operation_id': 'get_segment',
'http_method': 'GET',
'servers': None,
},
params_map={
'all': [
'app_id',
'segment_id',
'include_segment_detail',
],
'required': [
'app_id',
'segment_id',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'app_id':
(str,),
'segment_id':
(str,),
'include_segment_detail':
(bool,),
},
'attribute_map': {
'app_id': 'app_id',
'segment_id': 'segment_id',
'include_segment_detail': 'include-segment-detail',
},
'location_map': {
'app_id': 'path',
'segment_id': 'path',
'include_segment_detail': 'query',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [],
},
api_client=api_client
)
self.get_segments_endpoint = _Endpoint(
settings={
'response_type': (GetSegmentsSuccessResponse,),
Expand Down Expand Up @@ -5203,6 +5266,94 @@ def get_outcomes(
outcome_names
return self.get_outcomes_endpoint.call_with_http_info(**kwargs)

def get_segment(
self,
app_id,
segment_id,
**kwargs
):
"""View Segment # noqa: E501

Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. # 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_segment(app_id, segment_id, async_req=True)
>>> result = thread.get()

Args:
app_id (str): The OneSignal App ID for your app. Available in Keys & IDs.
segment_id (str): The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard.

Keyword Args:
include_segment_detail (bool): Set to true to include segment metadata and filters in the response.. [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 (int/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.
_spec_property_naming (bool): True if the variable names in the input data
are serialized names, as specified in the OpenAPI document.
False if the variable names in the input data
are pythonic names, e.g. snake case (default)
_content_type (str/None): force body content-type.
Default is None and content-type will be predicted by allowed
content-types and body.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
_request_auths (list): set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
Default is None
async_req (bool): execute request asynchronously

Returns:
GetSegmentSuccessResponse
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['_spec_property_naming'] = kwargs.get(
'_spec_property_naming', False
)
kwargs['_content_type'] = kwargs.get(
'_content_type')
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['_request_auths'] = kwargs.get('_request_auths', None)
kwargs['app_id'] = \
app_id
kwargs['segment_id'] = \
segment_id
return self.get_segment_endpoint.call_with_http_info(**kwargs)

def get_segments(
self,
app_id,
Expand Down
Loading