1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
#[allow(warnings)]
use hyper::Client;
use hyper::status::StatusCode;
use rusoto_core::request::DispatchSignedRequest;
use rusoto_core::region;

use std::fmt;
use std::error::Error;
use rusoto_core::request::HttpDispatchError;
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};

use serde_json;
use rusoto_core::signature::SignedRequest;
use serde_json::Value as SerdeJsonValue;
use serde_json::from_str;
#[doc="<p>A BatchMeterUsageRequest contains UsageRecords, which indicate quantities of usage within your application.</p>"]
#[derive(Default,Debug,Clone,Serialize)]
pub struct BatchMeterUsageRequest {
    #[doc="<p>Product code is used to uniquely identify a product in AWS Marketplace. The product code should be the same as the one used during the publishing of a new product.</p>"]
    #[serde(rename="ProductCode")]
    pub product_code: ProductCode,
    #[doc="<p>The set of UsageRecords to submit. BatchMeterUsage accepts up to 25 UsageRecords at a time.</p>"]
    #[serde(rename="UsageRecords")]
    pub usage_records: UsageRecordList,
}

#[doc="<p>Contains the UsageRecords processed by BatchMeterUsage and any records that have failed due to transient error.</p>"]
#[derive(Default,Debug,Clone,Deserialize)]
pub struct BatchMeterUsageResult {
    #[doc="<p>Contains all UsageRecords processed by BatchMeterUsage. These records were either honored by AWS Marketplace Metering Service or were invalid.</p>"]
    #[serde(rename="Results")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub results: Option<UsageRecordResultList>,
    #[doc="<p>Contains all UsageRecords that were not processed by BatchMeterUsage. This is a list of UsageRecords. You can retry the failed request by making another BatchMeterUsage call with this list as input in the BatchMeterUsageRequest.</p>"]
    #[serde(rename="UnprocessedRecords")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub unprocessed_records: Option<UsageRecordList>,
}

pub type Boolean = bool;
pub type CustomerIdentifier = String;
pub type ErrorMessage = String;
#[derive(Default,Debug,Clone,Serialize)]
pub struct MeterUsageRequest {
    #[doc="<p>Checks whether you have the permissions required for the action, but does not make the request. If you have the permissions, the request returns DryRunOperation; otherwise, it returns UnauthorizedException.</p>"]
    #[serde(rename="DryRun")]
    pub dry_run: Boolean,
    #[doc="<p>Product code is used to uniquely identify a product in AWS Marketplace. The product code should be the same as the one used during the publishing of a new product.</p>"]
    #[serde(rename="ProductCode")]
    pub product_code: ProductCode,
    #[doc="<p>Timestamp of the hour, recorded in UTC. The seconds and milliseconds portions of the timestamp will be ignored.</p>"]
    #[serde(rename="Timestamp")]
    pub timestamp: Timestamp,
    #[doc="<p>It will be one of the fcp dimension name provided during the publishing of the product.</p>"]
    #[serde(rename="UsageDimension")]
    pub usage_dimension: UsageDimension,
    #[doc="<p>Consumption value for the hour.</p>"]
    #[serde(rename="UsageQuantity")]
    pub usage_quantity: UsageQuantity,
}

#[derive(Default,Debug,Clone,Deserialize)]
pub struct MeterUsageResult {
    #[serde(rename="MeteringRecordId")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub metering_record_id: Option<String>,
}

pub type NonEmptyString = String;
pub type ProductCode = String;
#[doc="<p>Contains input to the ResolveCustomer operation.</p>"]
#[derive(Default,Debug,Clone,Serialize)]
pub struct ResolveCustomerRequest {
    #[doc="<p>When a buyer visits your website during the registration process, the buyer submits a registration token through the browser. The registration token is resolved to obtain a CustomerIdentifier and product code.</p>"]
    #[serde(rename="RegistrationToken")]
    pub registration_token: NonEmptyString,
}

#[doc="<p>The result of the ResolveCustomer operation. Contains the CustomerIdentifier and product code.</p>"]
#[derive(Default,Debug,Clone,Deserialize)]
pub struct ResolveCustomerResult {
    #[doc="<p>The CustomerIdentifier is used to identify an individual customer in your application. Calls to BatchMeterUsage require CustomerIdentifiers for each UsageRecord.</p>"]
    #[serde(rename="CustomerIdentifier")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub customer_identifier: Option<CustomerIdentifier>,
    #[doc="<p>The product code is returned to confirm that the buyer is registering for your product. Subsequent BatchMeterUsage calls should be made using this product code.</p>"]
    #[serde(rename="ProductCode")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub product_code: Option<ProductCode>,
}

pub type Timestamp = f64;
pub type UsageDimension = String;
pub type UsageQuantity = i64;
#[doc="<p>A UsageRecord indicates a quantity of usage for a given product, customer, dimension and time.</p> <p>Multiple requests with the same UsageRecords as input will be deduplicated to prevent double charges.</p>"]
#[derive(Default,Debug,Clone,Serialize,Deserialize)]
pub struct UsageRecord {
    #[doc="<p>The CustomerIdentifier is obtained through the ResolveCustomer operation and represents an individual buyer in your application.</p>"]
    #[serde(rename="CustomerIdentifier")]
    pub customer_identifier: CustomerIdentifier,
    #[doc="<p>During the process of registering a product on AWS Marketplace, up to eight dimensions are specified. These represent different units of value in your application.</p>"]
    #[serde(rename="Dimension")]
    pub dimension: UsageDimension,
    #[doc="<p>The quantity of usage consumed by the customer for the given dimension and time.</p>"]
    #[serde(rename="Quantity")]
    pub quantity: UsageQuantity,
    #[doc="<p>Timestamp of the hour, recorded in UTC. The seconds and milliseconds portions of the timestamp will be ignored.</p> <p>Your application can meter usage for up to one hour in the past.</p>"]
    #[serde(rename="Timestamp")]
    pub timestamp: Timestamp,
}

pub type UsageRecordList = Vec<UsageRecord>;
#[doc="<p>A UsageRecordResult indicates the status of a given UsageRecord processed by BatchMeterUsage.</p>"]
#[derive(Default,Debug,Clone,Deserialize)]
pub struct UsageRecordResult {
    #[doc="<p>The MeteringRecordId is a unique identifier for this metering event.</p>"]
    #[serde(rename="MeteringRecordId")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub metering_record_id: Option<String>,
    #[doc="<p>The UsageRecordResult Status indicates the status of an individual UsageRecord processed by BatchMeterUsage.</p> <ul> <li> <p> <i>Success</i>- The UsageRecord was accepted and honored by BatchMeterUsage.</p> </li> <li> <p> <i>CustomerNotSubscribed</i>- The CustomerIdentifier specified is not subscribed to your product. The UsageRecord was not honored. Future UsageRecords for this customer will fail until the customer subscribes to your product.</p> </li> <li> <p> <i>DuplicateRecord</i>- Indicates that the UsageRecord was invalid and not honored. A previously metered UsageRecord had the same customer, dimension, and time, but a different quantity.</p> </li> </ul>"]
    #[serde(rename="Status")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub status: Option<UsageRecordResultStatus>,
    #[doc="<p>The UsageRecord that was part of the BatchMeterUsage request.</p>"]
    #[serde(rename="UsageRecord")]
    #[serde(skip_serializing_if="Option::is_none")]
    pub usage_record: Option<UsageRecord>,
}

pub type UsageRecordResultList = Vec<UsageRecordResult>;
pub type UsageRecordResultStatus = String;
/// Errors returned by BatchMeterUsage
#[derive(Debug, PartialEq)]
pub enum BatchMeterUsageError {
    ///<p>An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.</p>
    InternalServiceError(String),
    ///<p>You have metered usage for a CustomerIdentifier that does not exist.</p>
    InvalidCustomerIdentifier(String),
    ///<p>The product code passed does not match the product code used for publishing the product.</p>
    InvalidProductCode(String),
    ///<p>The usage dimension does not match one of the UsageDimensions associated with products.</p>
    InvalidUsageDimension(String),
    ///<p>The calls to the MeterUsage API are throttled.</p>
    Throttling(String),
    ///<p>The timestamp value passed in the meterUsage() is out of allowed range.</p>
    TimestampOutOfBounds(String),
    /// An error occurred dispatching the HTTP request
    HttpDispatch(HttpDispatchError),
    /// An error was encountered with AWS credentials.
    Credentials(CredentialsError),
    /// A validation error occurred.  Details from AWS are provided.
    Validation(String),
    /// An unknown error occurred.  The raw HTTP response is provided.
    Unknown(String),
}


impl BatchMeterUsageError {
    pub fn from_body(body: &str) -> BatchMeterUsageError {
        match from_str::<SerdeJsonValue>(body) {
            Ok(json) => {
                let raw_error_type = json.get("__type")
                    .and_then(|e| e.as_str())
                    .unwrap_or("Unknown");
                let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or(body);

                let pieces: Vec<&str> = raw_error_type.split("#").collect();
                let error_type = pieces.last().expect("Expected error type");

                match *error_type {
                    "InternalServiceErrorException" => {
                        BatchMeterUsageError::InternalServiceError(String::from(error_message))
                    }
                    "InvalidCustomerIdentifierException" => {
                        BatchMeterUsageError::InvalidCustomerIdentifier(String::from(error_message))
                    }
                    "InvalidProductCodeException" => {
                        BatchMeterUsageError::InvalidProductCode(String::from(error_message))
                    }
                    "InvalidUsageDimensionException" => {
                        BatchMeterUsageError::InvalidUsageDimension(String::from(error_message))
                    }
                    "ThrottlingException" => {
                        BatchMeterUsageError::Throttling(String::from(error_message))
                    }
                    "TimestampOutOfBoundsException" => {
                        BatchMeterUsageError::TimestampOutOfBounds(String::from(error_message))
                    }
                    "ValidationException" => {
                        BatchMeterUsageError::Validation(error_message.to_string())
                    }
                    _ => BatchMeterUsageError::Unknown(String::from(body)),
                }
            }
            Err(_) => BatchMeterUsageError::Unknown(String::from(body)),
        }
    }
}

impl From<serde_json::error::Error> for BatchMeterUsageError {
    fn from(err: serde_json::error::Error) -> BatchMeterUsageError {
        BatchMeterUsageError::Unknown(err.description().to_string())
    }
}
impl From<CredentialsError> for BatchMeterUsageError {
    fn from(err: CredentialsError) -> BatchMeterUsageError {
        BatchMeterUsageError::Credentials(err)
    }
}
impl From<HttpDispatchError> for BatchMeterUsageError {
    fn from(err: HttpDispatchError) -> BatchMeterUsageError {
        BatchMeterUsageError::HttpDispatch(err)
    }
}
impl fmt::Display for BatchMeterUsageError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.description())
    }
}
impl Error for BatchMeterUsageError {
    fn description(&self) -> &str {
        match *self {
            BatchMeterUsageError::InternalServiceError(ref cause) => cause,
            BatchMeterUsageError::InvalidCustomerIdentifier(ref cause) => cause,
            BatchMeterUsageError::InvalidProductCode(ref cause) => cause,
            BatchMeterUsageError::InvalidUsageDimension(ref cause) => cause,
            BatchMeterUsageError::Throttling(ref cause) => cause,
            BatchMeterUsageError::TimestampOutOfBounds(ref cause) => cause,
            BatchMeterUsageError::Validation(ref cause) => cause,
            BatchMeterUsageError::Credentials(ref err) => err.description(),
            BatchMeterUsageError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
            BatchMeterUsageError::Unknown(ref cause) => cause,
        }
    }
}
/// Errors returned by MeterUsage
#[derive(Debug, PartialEq)]
pub enum MeterUsageError {
    ///<p>A metering record has already been emitted by the same EC2 instance for the given {usageDimension, timestamp} with a different usageQuantity.</p>
    DuplicateRequest(String),
    ///<p>An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.</p>
    InternalServiceError(String),
    ///<p>The endpoint being called is in a region different from your EC2 instance. The region of the Metering service endpoint and the region of the EC2 instance must match.</p>
    InvalidEndpointRegion(String),
    ///<p>The product code passed does not match the product code used for publishing the product.</p>
    InvalidProductCode(String),
    ///<p>The usage dimension does not match one of the UsageDimensions associated with products.</p>
    InvalidUsageDimension(String),
    ///<p>The calls to the MeterUsage API are throttled.</p>
    Throttling(String),
    ///<p>The timestamp value passed in the meterUsage() is out of allowed range.</p>
    TimestampOutOfBounds(String),
    /// An error occurred dispatching the HTTP request
    HttpDispatch(HttpDispatchError),
    /// An error was encountered with AWS credentials.
    Credentials(CredentialsError),
    /// A validation error occurred.  Details from AWS are provided.
    Validation(String),
    /// An unknown error occurred.  The raw HTTP response is provided.
    Unknown(String),
}


impl MeterUsageError {
    pub fn from_body(body: &str) -> MeterUsageError {
        match from_str::<SerdeJsonValue>(body) {
            Ok(json) => {
                let raw_error_type = json.get("__type")
                    .and_then(|e| e.as_str())
                    .unwrap_or("Unknown");
                let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or(body);

                let pieces: Vec<&str> = raw_error_type.split("#").collect();
                let error_type = pieces.last().expect("Expected error type");

                match *error_type {
                    "DuplicateRequestException" => {
                        MeterUsageError::DuplicateRequest(String::from(error_message))
                    }
                    "InternalServiceErrorException" => {
                        MeterUsageError::InternalServiceError(String::from(error_message))
                    }
                    "InvalidEndpointRegionException" => {
                        MeterUsageError::InvalidEndpointRegion(String::from(error_message))
                    }
                    "InvalidProductCodeException" => {
                        MeterUsageError::InvalidProductCode(String::from(error_message))
                    }
                    "InvalidUsageDimensionException" => {
                        MeterUsageError::InvalidUsageDimension(String::from(error_message))
                    }
                    "ThrottlingException" => {
                        MeterUsageError::Throttling(String::from(error_message))
                    }
                    "TimestampOutOfBoundsException" => {
                        MeterUsageError::TimestampOutOfBounds(String::from(error_message))
                    }
                    "ValidationException" => MeterUsageError::Validation(error_message.to_string()),
                    _ => MeterUsageError::Unknown(String::from(body)),
                }
            }
            Err(_) => MeterUsageError::Unknown(String::from(body)),
        }
    }
}

impl From<serde_json::error::Error> for MeterUsageError {
    fn from(err: serde_json::error::Error) -> MeterUsageError {
        MeterUsageError::Unknown(err.description().to_string())
    }
}
impl From<CredentialsError> for MeterUsageError {
    fn from(err: CredentialsError) -> MeterUsageError {
        MeterUsageError::Credentials(err)
    }
}
impl From<HttpDispatchError> for MeterUsageError {
    fn from(err: HttpDispatchError) -> MeterUsageError {
        MeterUsageError::HttpDispatch(err)
    }
}
impl fmt::Display for MeterUsageError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.description())
    }
}
impl Error for MeterUsageError {
    fn description(&self) -> &str {
        match *self {
            MeterUsageError::DuplicateRequest(ref cause) => cause,
            MeterUsageError::InternalServiceError(ref cause) => cause,
            MeterUsageError::InvalidEndpointRegion(ref cause) => cause,
            MeterUsageError::InvalidProductCode(ref cause) => cause,
            MeterUsageError::InvalidUsageDimension(ref cause) => cause,
            MeterUsageError::Throttling(ref cause) => cause,
            MeterUsageError::TimestampOutOfBounds(ref cause) => cause,
            MeterUsageError::Validation(ref cause) => cause,
            MeterUsageError::Credentials(ref err) => err.description(),
            MeterUsageError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
            MeterUsageError::Unknown(ref cause) => cause,
        }
    }
}
/// Errors returned by ResolveCustomer
#[derive(Debug, PartialEq)]
pub enum ResolveCustomerError {
    ///<p>The submitted registration token has expired. This can happen if the buyer's browser takes too long to redirect to your page, the buyer has resubmitted the registration token, or your application has held on to the registration token for too long. Your SaaS registration website should redeem this token as soon as it is submitted by the buyer's browser.</p>
    ExpiredToken(String),
    ///<p>An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.</p>
    InternalServiceError(String),
    ///
    InvalidToken(String),
    ///<p>The calls to the MeterUsage API are throttled.</p>
    Throttling(String),
    /// An error occurred dispatching the HTTP request
    HttpDispatch(HttpDispatchError),
    /// An error was encountered with AWS credentials.
    Credentials(CredentialsError),
    /// A validation error occurred.  Details from AWS are provided.
    Validation(String),
    /// An unknown error occurred.  The raw HTTP response is provided.
    Unknown(String),
}


impl ResolveCustomerError {
    pub fn from_body(body: &str) -> ResolveCustomerError {
        match from_str::<SerdeJsonValue>(body) {
            Ok(json) => {
                let raw_error_type = json.get("__type")
                    .and_then(|e| e.as_str())
                    .unwrap_or("Unknown");
                let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or(body);

                let pieces: Vec<&str> = raw_error_type.split("#").collect();
                let error_type = pieces.last().expect("Expected error type");

                match *error_type {
                    "ExpiredTokenException" => {
                        ResolveCustomerError::ExpiredToken(String::from(error_message))
                    }
                    "InternalServiceErrorException" => {
                        ResolveCustomerError::InternalServiceError(String::from(error_message))
                    }
                    "InvalidTokenException" => {
                        ResolveCustomerError::InvalidToken(String::from(error_message))
                    }
                    "ThrottlingException" => {
                        ResolveCustomerError::Throttling(String::from(error_message))
                    }
                    "ValidationException" => {
                        ResolveCustomerError::Validation(error_message.to_string())
                    }
                    _ => ResolveCustomerError::Unknown(String::from(body)),
                }
            }
            Err(_) => ResolveCustomerError::Unknown(String::from(body)),
        }
    }
}

impl From<serde_json::error::Error> for ResolveCustomerError {
    fn from(err: serde_json::error::Error) -> ResolveCustomerError {
        ResolveCustomerError::Unknown(err.description().to_string())
    }
}
impl From<CredentialsError> for ResolveCustomerError {
    fn from(err: CredentialsError) -> ResolveCustomerError {
        ResolveCustomerError::Credentials(err)
    }
}
impl From<HttpDispatchError> for ResolveCustomerError {
    fn from(err: HttpDispatchError) -> ResolveCustomerError {
        ResolveCustomerError::HttpDispatch(err)
    }
}
impl fmt::Display for ResolveCustomerError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.description())
    }
}
impl Error for ResolveCustomerError {
    fn description(&self) -> &str {
        match *self {
            ResolveCustomerError::ExpiredToken(ref cause) => cause,
            ResolveCustomerError::InternalServiceError(ref cause) => cause,
            ResolveCustomerError::InvalidToken(ref cause) => cause,
            ResolveCustomerError::Throttling(ref cause) => cause,
            ResolveCustomerError::Validation(ref cause) => cause,
            ResolveCustomerError::Credentials(ref err) => err.description(),
            ResolveCustomerError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
            ResolveCustomerError::Unknown(ref cause) => cause,
        }
    }
}
/// Trait representing the capabilities of the AWSMarketplace Metering API. AWSMarketplace Metering clients implement this trait.
pub trait MarketplaceMetering {
    #[doc="<p>BatchMeterUsage is called from a SaaS application listed on the AWS Marketplace to post metering records for a set of customers.</p> <p>For identical requests, the API is idempotent; requests can be retried with the same records or a subset of the input records.</p> <p>Every request to BatchMeterUsage is for one product. If you need to meter usage for multiple products, you must make multiple calls to BatchMeterUsage.</p> <p>BatchMeterUsage can process up to 25 UsageRecords at a time.</p>"]
    fn batch_meter_usage(&self,
                         input: &BatchMeterUsageRequest)
                         -> Result<BatchMeterUsageResult, BatchMeterUsageError>;


    #[doc="<p>API to emit metering records. For identical requests, the API is idempotent. It simply returns the metering record ID.</p> <p>MeterUsage is authenticated on the buyer's AWS account, generally when running from an EC2 instance on the AWS Marketplace.</p>"]
    fn meter_usage(&self, input: &MeterUsageRequest) -> Result<MeterUsageResult, MeterUsageError>;


    #[doc="<p>ResolveCustomer is called by a SaaS application during the registration process. When a buyer visits your website during the registration process, the buyer submits a registration token through their browser. The registration token is resolved through this API to obtain a CustomerIdentifier and product code.</p>"]
    fn resolve_customer(&self,
                        input: &ResolveCustomerRequest)
                        -> Result<ResolveCustomerResult, ResolveCustomerError>;
}
/// A client for the AWSMarketplace Metering API.
pub struct MarketplaceMeteringClient<P, D>
    where P: ProvideAwsCredentials,
          D: DispatchSignedRequest
{
    credentials_provider: P,
    region: region::Region,
    dispatcher: D,
}

impl<P, D> MarketplaceMeteringClient<P, D>
    where P: ProvideAwsCredentials,
          D: DispatchSignedRequest
{
    pub fn new(request_dispatcher: D, credentials_provider: P, region: region::Region) -> Self {
        MarketplaceMeteringClient {
            credentials_provider: credentials_provider,
            region: region,
            dispatcher: request_dispatcher,
        }
    }
}

impl<P, D> MarketplaceMetering for MarketplaceMeteringClient<P, D>
    where P: ProvideAwsCredentials,
          D: DispatchSignedRequest
{
    #[doc="<p>BatchMeterUsage is called from a SaaS application listed on the AWS Marketplace to post metering records for a set of customers.</p> <p>For identical requests, the API is idempotent; requests can be retried with the same records or a subset of the input records.</p> <p>Every request to BatchMeterUsage is for one product. If you need to meter usage for multiple products, you must make multiple calls to BatchMeterUsage.</p> <p>BatchMeterUsage can process up to 25 UsageRecords at a time.</p>"]
    fn batch_meter_usage(&self,
                         input: &BatchMeterUsageRequest)
                         -> Result<BatchMeterUsageResult, BatchMeterUsageError> {
        let mut request = SignedRequest::new("POST", "aws-marketplace", self.region, "/");
        request.set_endpoint_prefix("metering.marketplace".to_string());
        request.set_content_type("application/x-amz-json-1.1".to_owned());
        request.add_header("x-amz-target", "AWSMPMeteringService.BatchMeterUsage");
        let encoded = serde_json::to_string(input).unwrap();
        request.set_payload(Some(encoded.into_bytes()));

        request.sign(&try!(self.credentials_provider.credentials()));

        let response = try!(self.dispatcher.dispatch(&request));

        match response.status {
            StatusCode::Ok => {
                            Ok(serde_json::from_str::<BatchMeterUsageResult>(String::from_utf8_lossy(&response.body).as_ref()).unwrap())
                        }
            _ => {
                Err(BatchMeterUsageError::from_body(String::from_utf8_lossy(&response.body)
                                                        .as_ref()))
            }
        }
    }


    #[doc="<p>API to emit metering records. For identical requests, the API is idempotent. It simply returns the metering record ID.</p> <p>MeterUsage is authenticated on the buyer's AWS account, generally when running from an EC2 instance on the AWS Marketplace.</p>"]
    fn meter_usage(&self, input: &MeterUsageRequest) -> Result<MeterUsageResult, MeterUsageError> {
        let mut request = SignedRequest::new("POST", "aws-marketplace", self.region, "/");
        request.set_endpoint_prefix("metering.marketplace".to_string());
        request.set_content_type("application/x-amz-json-1.1".to_owned());
        request.add_header("x-amz-target", "AWSMPMeteringService.MeterUsage");
        let encoded = serde_json::to_string(input).unwrap();
        request.set_payload(Some(encoded.into_bytes()));

        request.sign(&try!(self.credentials_provider.credentials()));

        let response = try!(self.dispatcher.dispatch(&request));

        match response.status {
            StatusCode::Ok => {
                            Ok(serde_json::from_str::<MeterUsageResult>(String::from_utf8_lossy(&response.body).as_ref()).unwrap())
                        }
            _ => Err(MeterUsageError::from_body(String::from_utf8_lossy(&response.body).as_ref())),
        }
    }


    #[doc="<p>ResolveCustomer is called by a SaaS application during the registration process. When a buyer visits your website during the registration process, the buyer submits a registration token through their browser. The registration token is resolved through this API to obtain a CustomerIdentifier and product code.</p>"]
    fn resolve_customer(&self,
                        input: &ResolveCustomerRequest)
                        -> Result<ResolveCustomerResult, ResolveCustomerError> {
        let mut request = SignedRequest::new("POST", "aws-marketplace", self.region, "/");
        request.set_endpoint_prefix("metering.marketplace".to_string());
        request.set_content_type("application/x-amz-json-1.1".to_owned());
        request.add_header("x-amz-target", "AWSMPMeteringService.ResolveCustomer");
        let encoded = serde_json::to_string(input).unwrap();
        request.set_payload(Some(encoded.into_bytes()));

        request.sign(&try!(self.credentials_provider.credentials()));

        let response = try!(self.dispatcher.dispatch(&request));

        match response.status {
            StatusCode::Ok => {
                            Ok(serde_json::from_str::<ResolveCustomerResult>(String::from_utf8_lossy(&response.body).as_ref()).unwrap())
                        }
            _ => {
                Err(ResolveCustomerError::from_body(String::from_utf8_lossy(&response.body)
                                                        .as_ref()))
            }
        }
    }
}

#[cfg(test)]
mod protocol_tests {}