|
| 1 | +from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse |
| 2 | + |
| 3 | +class NegativeTargets(Client): |
| 4 | + """Amazon Advertising API for Sponsored Display |
| 5 | +
|
| 6 | + Documentation: https://advertising.amazon.com/API/docs/en-us/sponsored-display/3-0/openapi#/Negative%20targeting |
| 7 | +
|
| 8 | + This API enables programmatic access for campaign creation, management, and reporting for Sponsored Display campaigns. For more information on the functionality, see the `Sponsored Display Support Center <https://advertising.amazon.com/help#GTPPHE6RAWC2C4LZ>`_ . For API onboarding information, see the `account setup <https://advertising.amazon.com/API/docs/en-us/setting-up/account-setup>`_ topic. |
| 9 | +
|
| 10 | + This specification is available for download from the `Advertising API developer portal <https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/sponsored-display/3-0/openapi.yaml>`_. |
| 11 | +
|
| 12 | + """ |
| 13 | + |
| 14 | + @sp_endpoint('/sd/negativeTargets', method='GET') |
| 15 | + def list_negative_targets(self, **kwargs) -> ApiResponse: |
| 16 | + r""" |
| 17 | + list_negative_targets(self, \*\*kwargs) -> ApiResponse |
| 18 | +
|
| 19 | + Gets a list of negative targeting clauses filtered by specified criteria. |
| 20 | +
|
| 21 | + | query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0 |
| 22 | + | query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size. |
| 23 | + | query **stateFilter**:*string* | Optional. The returned array is filtered to include only ad groups with state set to one of the values in the specified comma-delimited list. Available values : enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived Default value : enabled, paused, archived. |
| 24 | + | query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers. |
| 25 | + | query **adGroupIdFilter**:*string* | Optional. Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. |
| 26 | + | query **targetIdFilter**:*string* | Optional. A comma-delimited list of target identifiers. Missing in official Amazon documentation |
| 27 | +
|
| 28 | + Returns: |
| 29 | +
|
| 30 | + ApiResponse |
| 31 | +
|
| 32 | + """ |
| 33 | + return self._request(kwargs.pop('path'), params=kwargs) |
| 34 | + |
| 35 | + @sp_endpoint('/sd/negativeTargets', method='PUT') |
| 36 | + def edit_negative_targets(self, **kwargs) -> ApiResponse: |
| 37 | + r""" |
| 38 | + Updates one or more negative targeting clauses. Negative targeting clauses are identified using their targetId. The mutable field is state. Maximum length of the array is 100 objects. |
| 39 | +
|
| 40 | + body: | UpdateNegativeTargetingClause REQUIRED {'description': 'A list of up to 100 negative targeting clauses. Note that the only mutable field is state.}' |
| 41 | +
|
| 42 | + | '**state**': *number*, {'description': 'The resource state. [ enabled, paused, archived ]'} |
| 43 | + | '**targetId***': *integer($int64)*, {'description': 'The identifier of the TargetId.'} |
| 44 | +
|
| 45 | + Returns: |
| 46 | +
|
| 47 | + ApiResponse |
| 48 | +
|
| 49 | +
|
| 50 | + """ |
| 51 | + return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs) |
| 52 | + |
| 53 | + |
| 54 | + @sp_endpoint('/sd/negativeTargets', method='POST') |
| 55 | + def create_negative_targets(self, **kwargs) -> ApiResponse: |
| 56 | + r""" |
| 57 | + create_products_targets(self, \*\*kwargs) -> ApiResponse: |
| 58 | +
|
| 59 | + Creates one or more targeting expressions. |
| 60 | +
|
| 61 | + body: | REQUIRED {'description': 'An array of asins objects.}' |
| 62 | +
|
| 63 | + | '**state**': *number*, {'description': 'The current resource state. [ enabled, paused, archived ]'} |
| 64 | + | '**adGroupId**': *number*, {'description': 'The identifier of the ad group to which this negative target is associated.'} |
| 65 | + | '**expression**' |
| 66 | + | '**type**': *string*, {'description': 'The intent type. See the targeting topic in the Amazon Advertising support center for more information.', 'enum': '[ asinSameAs, asinBrandSameAs ]'} |
| 67 | + | '**value**': *string*, {'description': 'The value to be negatively targeted. Used only in manual expressions.'} |
| 68 | + | '**expressionType**': *string*, {'description': '[ auto, manual ]'} |
| 69 | +
|
| 70 | + Returns: |
| 71 | +
|
| 72 | + ApiResponse |
| 73 | +
|
| 74 | +
|
| 75 | + """ |
| 76 | + return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs) |
| 77 | + |
| 78 | + |
| 79 | + @sp_endpoint('/sd/negativeTargets/{}', method='GET') |
| 80 | + def get_negative_target(self, targetId, **kwargs) -> ApiResponse: |
| 81 | + r""" |
| 82 | +
|
| 83 | + This call returns the minimal set of negative targeting clause fields, but is more efficient than getNegativeTargetsEx. |
| 84 | +
|
| 85 | + Get a negative targeting clause specified by identifier. |
| 86 | +
|
| 87 | + path **negativeTargetId**:*integer* | Required. The negative targeting clause identifier. |
| 88 | +
|
| 89 | + Returns: |
| 90 | +
|
| 91 | + ApiResponse |
| 92 | +
|
| 93 | + """ |
| 94 | + return self._request(fill_query_params(kwargs.pop('path'), targetId), params=kwargs) |
| 95 | + |
| 96 | + @sp_endpoint('/sd/negativeTargets/{}', method='DELETE') |
| 97 | + def delete_negative_targets(self, targetId, **kwargs) -> ApiResponse: |
| 98 | + r""" |
| 99 | +
|
| 100 | + Equivalent to using the updateNegativeTargetingClauses operation to set the state property of a targeting clause to archived. See Developer Notes for more information. |
| 101 | +
|
| 102 | + Archives a negative targeting clause. |
| 103 | +
|
| 104 | + path **negativeTargetId**:*integer* | Required. The negative targeting clause identifier. |
| 105 | +
|
| 106 | + Returns: |
| 107 | +
|
| 108 | + ApiResponse |
| 109 | +
|
| 110 | + """ |
| 111 | + return self._request(fill_query_params(kwargs.pop('path'), targetId), params=kwargs) |
| 112 | + |
| 113 | + @sp_endpoint('/sd/negativeTargets/extended', method='GET') |
| 114 | + def list_negative_targets_extended(self, **kwargs) -> ApiResponse: |
| 115 | + r""" |
| 116 | + Gets an array of NegativeTargetingClauseEx objects for a set of requested negative targets. Note that this call returns the full set of negative targeting clause extended fields, but is less efficient than getNegativeTargets. |
| 117 | +
|
| 118 | + | query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0 |
| 119 | + | query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size. |
| 120 | + | query **stateFilter**:*string* | Optional. The returned array is filtered to include only ad groups with state set to one of the values in the specified comma-delimited list. Available values : enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived Default value : enabled, paused, archived. |
| 121 | + | query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers. |
| 122 | + | query **adGroupIdFilter**:*string* | Optional. Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. |
| 123 | + | query **targetIdFilter**:*string* | Optional. A comma-delimited list of target identifiers. Missing in official Amazon documentation |
| 124 | +
|
| 125 | + Returns: |
| 126 | +
|
| 127 | + ApiResponse |
| 128 | +
|
| 129 | + """ |
| 130 | + return self._request(kwargs.pop('path'), params=kwargs) |
| 131 | + |
| 132 | + @sp_endpoint('/sd/negativeTargets/extended/{}', method='GET') |
| 133 | + def get_negative_target_extended(self, targetId, **kwargs) -> ApiResponse: |
| 134 | + r""" |
| 135 | + Gets a negative targeting clause with extended fields. Note that this call returns the full set of negative targeting clause extended fields, but is less efficient than getNegativeTarget. |
| 136 | +
|
| 137 | + path **negativeTargetId**:*integer* | Required. The negative targeting clause identifier. |
| 138 | +
|
| 139 | + Returns: |
| 140 | +
|
| 141 | + ApiResponse |
| 142 | +
|
| 143 | + """ |
| 144 | + return self._request(fill_query_params(kwargs.pop('path'), targetId), params=kwargs) |
0 commit comments