AWS Provider

Provide the classes to associate a VHD image into a product on AWS Marketplace.

Note

Uses Boto3 to access AWS Marketplace public API.

Index:

Providers

class cloudpub.aws.AWSVersionMetadata(version_mapping, marketplace_entity_type, **kwargs)[source]

A collection of metadata necessary for publishing a AMI into a product.

__init__(version_mapping, marketplace_entity_type, **kwargs)[source]

Create a new AWS Version Metadata object.

Parameters:
  • version_mapping (VersionMapping) – A mapping of all the information to add a new version

  • marketplace_entity_type (str) – Product type of the AWS product Example: AmiProduct

class cloudpub.aws.AWSProductService(access_id, secret_key, region='us-east-1', attempts=288, interval=600)[source]

Create a new service provider for AWS using Boto3.

__init__(access_id, secret_key, region='us-east-1', attempts=288, interval=600)[source]

AWS cloud provider service.

Parameters:
  • access_id (str) – AWS account access ID

  • secret_key (str) – AWS account secret access key

  • region (str, optional) – AWS region for compute operations This defaults to ‘us-east-1’

  • attempts (int, optional) – Max number of times to poll while waiting for changeset Defaults to 288

  • interval (int, optional) – Seconds between polling while waiting for changeset Defaults to 600

cancel_change_set(change_set_id)[source]

Cancel the publish of a new version in progress.

Parameters:

change_set_id (str) – A change set id to cancel

Returns:

A change set id

Return type:

str

check_publish_status(change_set_id)[source]

Check the status of a change set.

Parameters:

change_set_id (str) – A change set id to check the status of

Returns:

Status of the publish

Return type:

str

Raises:

InvalidStateError if the job failed

get_product_active_changesets(entity_id)[source]

Get the active changesets for a product.

Parameters:

entity_id (str) – The Id of the entity to get active changesets from

Returns:

A change set id

Return type:

str

get_product_by_id(entity_id)[source]

Get a product detail by it’s id.

Parameters:

entity_id (str) – Entity id to get details from. If not set will default to class setting for EntityId.

Returns:

The details for a product

Return type:

ProductDetailResponse

Raises:

NotFoundError when the product is not found.

get_product_by_name(marketplace_entity_type, product_name)[source]

Get a product detail by it’s name.

Parameters:
  • marketplace_entity_type (str) – Product type of the AWS product Example: AmiProduct

  • product_name (str) – Name of a product

Returns:

A dict of details for the first response of a product

Return type:

str

Raises:
  • NotFoundError when the product is not found.

  • InvalidStateError when more than one product is found.

get_product_version_by_name(entity_id, version_name)[source]

Get a version detail by it’s name.

Parameters:
  • entity_id (str) – The Id of the entity to get version by name from

  • version_name (str) – A version title to get details of

Returns:

The delivery options of a version

Return type:

DeliveryOption

Raises:

NotFoundError when the product is not found.

get_product_version_details(entity_id, version_id)[source]

Get a product detail by it’s name.

Parameters:
  • entity_id (str) – The Id of the entity to get version details from

  • version_id (str) – The version id of a product to get the details of

Returns:

The details for the first response of a product

Return type:

ProductVersionsResponse

Raises:

NotFoundError when the product is not found.

get_product_versions(entity_id)[source]

Get the titles, ids, and date created of all the versions of a product.

Parameters:

entity_id (str) – The Id of the entity to get versions from

Returns:

A dictionary of versions

Return type:

Dict[str, GroupedVersions]

Raises:

NotFoundError when the product is not found.

publish(metadata)[source]

Add new version to an existing product.

Parameters:

new_version_details (VersionMapping) – A model of the version mapping

Return type:

None

restrict_versions(entity_id, marketplace_entity_type, restrict_major=None, restrict_minor=1)[source]

Restrict the old versions of a release.

Parameters:
  • entity_id (str) – The entity id to modifiy.

  • marketplace_entity_type (str) – Product type of the AWS product Example: AmiProduct

  • restrict_major (optional int) – How many major versions are allowed Example: 3

  • restrict_minor (optional int) – how many minor versions are allowed Example: 3

Returns:

List of AMI ids of restricted versions

Return type:

List[str]

set_restrict_versions(entity_id, marketplace_entity_type, delivery_option_ids)[source]

Restrict version(s) of a product by their id.

Parameters:
  • entity_id (str) – The Id of the entity to edit

  • marketplace_entity_type (str) – Product type of the AWS product Example: AmiProduct

  • delivery_option_ids (List) – A list of strs of delivery options to restrict. Normally version Ids.

Returns:

A change set id

Return type:

str

wait_active_changesets(entity_id)[source]

Get the first active changeset, if there is one, and wait for it to finish.

Parameters:

entity_id (str) – The Id of the entity to wait for active changesets

Return type:

None

wait_for_changeset(change_set_id)[source]

Wait until ChangeSet is complete.

Parameters:

change_set_id (str) – Id for the change set to wait on

Raises:
  • Timeout when the status doesn't change to either

  • 'Succeeded' or 'Failed' within the set retry time.

Return type:

None

AWS Models

The models used by AWSProductService.

The models are defined with attrs using the class AttrsJSONDecodeMixin to serialize/deserialize the JSON values for each request.

Note

This interacts with start_change_set in Boto3’s AWS Marketplace implementation.

Contents:

AWS Version Mapping

class cloudpub.models.aws.VersionMapping(version, delivery_options)[source]

Represent the version mapping information.

Attributes:

delivery_options: List[DeliveryOption]

Delivery Options object.

version: Version

Version object.

class cloudpub.models.aws.DeliveryOption(id, type, source_id, short_description, long_description, instructions, recommendations, visibility, details, title, ami_alias)[source]

Represent the delivery option information.

Attributes:

ami_alias: Optional[str]

Alias for the ami

details: DeliveryOptionsDetails

Details object for Delivery Options

id: str

AMI Id used for overwriting a current Version in AWS

instructions: DeliveryOptionsInstructions

Instructions on usage of this AMI

long_description: Optional[str]

Long description of Delivery option. (optional)

recommendations: DeliveryOptionsRecommendations

Recommendations when using this AMI

short_description: str

Short description of the delivery options

source_id: str

Source Id for the delivery option

title: str

Title for this DeliveryOption

type: str

Type of delivery option

Expected value:

  • AmazonMachineImage

visibility: Optional[str]

Define the visilibity of the current product within AWS marketplace.

Expected value (one of):

  • Public

  • Limited

  • Restricted

class cloudpub.models.aws.DeliveryOptionsRecommendations(instance_type, security_groups)[source]

Represent a single element of recommendations from class DeliveryOption.

Attributes:

instance_type: str

Instance type for this recommendation

security_groups: List[SecurityGroupRecommendations]

Security groups to use with this AMI.

class cloudpub.models.aws.DeliveryOptionsInstructions(usage, access)[source]

Represent a single element of instructions from class DeliveryOption.

Attributes:

access: Optional[DeliveryInstructionsAccess]

Instructions on how to access this AMI

usage: str

AMI usage instructions

class cloudpub.models.aws.DeliveryInstructionsAccess(type, port, protocol)[source]

Represent a single element of access from class DeliveryOptionsInstructions.

Attributes:

port: int

Port used for AMI access

protocol: str

Protocol to use for AMI access

type: str

Type instructions for access

class cloudpub.models.aws.DeliveryOptionsDetails(ami_delivery_options_details)[source]

Represent the ami delivery options information.

Attributes:

ami_delivery_options_details: AmiDeliveryOptionsDetails

Ami Delivery Options details

class cloudpub.models.aws.AmiDeliveryOptionsDetails(ami_source, usage_instructions, recommended_instance_type, security_groups, access_endpoint_url)[source]

Represent the delivery options details information.

Attributes:

access_endpoint_url: AccessEndpointUrl

Access endpoint url object

ami_source: AMISource

AMI Source object.

recommended_instance_type: str

Recommended instance type of the AMI. IE m5.medium

security_groups: List[SecurityGroup]

Security group object

usage_instructions: str

Instructions on the usage of the AMI instance.

class cloudpub.models.aws.SecurityGroup(from_port, ip_protocol, ip_ranges, to_port)[source]

Represent the security group information.

Attributes:

from_port: int

If the protocol is TCP or UDP, this is the start of the port range. If the protocol is ICMP or ICMPv6, this is the type number. A value of -1 indicates all ICMP/ICMPv6 types. If you specify all ICMP/ICMPv6 types, you must specify all ICMP/ICMPv6 codes.

ip_protocol: str

The IP protocol name ( tcp , udp , icmp , icmpv6 ).

ip_ranges: List[str]

The IPv4 ranges.

to_port: int

If the protocol is TCP or UDP, this is the end of the port range. If the protocol is ICMP or ICMPv6, this is the type number. A value of -1 indicates all ICMP/ICMPv6 types. If you specify all ICMP/ICMPv6 types, you must specify all ICMP/ICMPv6 codes.

class cloudpub.models.aws.AccessEndpointUrl(port, protocol)[source]

Represent the access endpoint url information.

Attributes:

port: int

Port to access the endpoint URL.

protocol: str

Protocol to access the endpoint URL (http, https).

class cloudpub.models.aws.Version(version_title, release_notes)[source]

Represent the version information.

Attributes:

release_notes: str

The release notes for the version update. This will provide what was updated in the version. Usually is a link to access.redhat.com for this version.

version_title: str

The title given to a version. This will display in AWS Marketplace as the name of the version.

class cloudpub.models.aws.AMISource(ami_id, access_role_arn, username, operating_system_name, operating_system_version, scanning_port)[source]

Represent the Ami Source information.

Attributes:

access_role_arn: str

The role to use to access to AMI.

ami_id: str

The Ami Id associated with the version update.

operating_system_name: str

The name of the Operating System used by the AMI.

operating_system_version: str

The version of the Operating System used by the AMI.

scanning_port: int

AMI scanning port, used when importing the AMI into AWS Marketplace to validate the AMI.

username: str

The username used to login to the AMI. (Usually set to ec2-user)

Product Resources

class cloudpub.models.aws.ProductDetailDescription(replacement_product_id, highlights, product_code, search_keywords, product_title, short_description, long_description, manufacturer, product_state, visibility, associated_products, sku, categories)[source]

Represent the “Details” section of the ProductDetailResponse.

Attributes:

associated_products: Optional[str]

Associated products within the current one.

categories: List[str]

The marketplace categories for the current product.

highlights: List[str]

List of highlights of the current product.

long_description: str

A detailed description of the product.

manufacturer: str

The product’s manufacturer name.

product_code: str

A unique code to identify the product within AWS.

product_state: str

The state of the current product.

Expected value (one of):

  • Available

  • Limited

product_title: str

The product title to be displayed in the marketplace

replacement_product_id: Optional[str]

The ID of the product which is replacing the current one, if applicable.

short_description: str

The summary of the product.

sku: Optional[str]

The SKUs for the current product.

visibility: str

Define the visilibity of the current product within AWS marketplace.

Expected value (one of):

  • Public

  • Limited

  • Restricted

class cloudpub.models.aws.ProductVersionsResponse(version_id, release_notes, upgrade_instructions, version_title, creation_date, sources, delivery_options)[source]

Represent the “Versions” section of the ProductDetailResponse.

Attributes:

creation_date: Optional[str]

The version’s creation date.

delivery_options: List[DeliveryOption]

The delivery options for the current version.

release_notes: Optional[str]

The version’s release notes.

sources: List[Union[ProductVersionsVirtualizationSource, ProductVersionsCloudFormationSource]]

The linked sources for the current version.

upgrade_instructions: Optional[str]

The instructions on how to upgrade from previous versions to the current one.

version_id: str

The ID of the current version.

version_title: Optional[str]

The name of the current version.

class cloudpub.models.aws.PromotionalResources(promotional_media, logo_url, additional_resources, videos)[source]

Represent the “PromotionalResources” section of the ProductDetailResponse.

Attributes:

additional_resources: List[AdditionalResources]

The product’s additional resources.

logo_url: str

The URL for the product’s logo.

promotional_media: Optional[str]

The product’s promotional media.

videos: List[PromoResourcesVideo]

The promotional/demonstration videos about the product.

class cloudpub.models.aws.Dimensions(types, description, unit, key, name)[source]

Represent a single element of dimensions from ProductDetailResponse.

Attributes:

description: Optional[str]

The dimensions description.

key: str

The dimension’s key.

name: str

The dimension’s name.

types: List[str]

The dimensions types.

unit: str

The unit measuring the dimensions consumption unit.

class cloudpub.models.aws.SupportInformation(description, resources)[source]

Represent the support_information attribute of ProductDetailResponse.

Attributes:

description: Optional[str]

The description of the provided support for the product.

resources: Optional[List[str]]

Additional resources for the provided support.

class cloudpub.models.aws.RegionAvailability(restrict, regions, future_region_support)[source]

Represent the region_availability attribute of ProductDetailResponse.

Attributes:

future_region_support: Optional[str]

The list of future avaialble regions for the current product.

regions: List[str]

The available regions for the current product.

restrict: List[str]

The list of restricted regions for the curent product.

class cloudpub.models.aws.TargetingDetail(positive_targeting)[source]

Represent the targeting attribute of ProductDetailResponse.

Attributes:

positive_targeting: PositiveTargeting

The positive targeting object for the TargetingDetail.

class cloudpub.models.aws.ProductDetailResponse(versions, description, promotional_resources, dimensions, support_information, region_availability, targeting, compatibility)[source]

Represent the parsed elements from “Details” of DescribeEntityResponse.

Attributes:

compatibility: Optional[SourcesCompatibility]

The product’s compatibility.

description: ProductDetailDescription

The product’s description.

dimensions: List[Dimensions]

The product’s dimensions.

promotional_resources: PromotionalResources

The product’s promotional resources.

region_availability: RegionAvailability

The product’s availability on AWS regions.

support_information: SupportInformation

The product’s support information.

targeting: TargetingDetail

The product’s targeting.

versions: List[ProductVersionsResponse]

The product’s versions list.

class cloudpub.models.aws.DescribeEntityResponse(type, identifier, arn, last_modified_date, details, details_document, meta)[source]

Represent the response of MarketplaceCatalog.Client.describe_entity.

Documentation

Attributes:

arn: str

The ARN associated to the unique identifier for the entity referenced in this request.

details: Optional[str]

This stringified JSON object includes the details of the entity.

details_document: ProductDetailResponse

This json object of the details of the entity.

identifier: str

The identifier of the entity, in the format of EntityId@RevisionId.

last_modified_date: str

22Z).

Type:

The last modified date of the entity, in ISO 8601 format (2018-02-27T13

Type:

45

meta: ResponseMetadata

The describe_entity response’s metadata.

type: str

The named type of the entity, in the format of EntityType@Version.

class cloudpub.models.aws.EntitySummary(name, entity_type, entity_id, entity_arn, last_modified_date, visibility)[source]

Represent a single element of attribute “entity_summary_list” of ListEntitiesResponse.

Attributes:

entity_arn: str

The ARN associated with the unique identifier for the entity.

entity_id: str

The unique identifier for the entity.

entity_type: str

The type of the entity.

last_modified_date: str

22Z).

Type:

The last time the entity was published, using ISO 8601 format (2018-02-27T13

Type:

45

name: str

The name for the entity. This value is not unique. It is defined by the seller.

visibility: str

The visibility status of the entity to buyers.

This value can be Public (everyone can view the entity), Limited (the entity is visible to limited accounts only), or Restricted (the entity was published and then unpublished and only existing buyers can view it).

class cloudpub.models.aws.ListEntitiesResponse(entity_summary_list, next_token)[source]

Represent the response of MarketplaceCatalog.Client.list_entities.

Documentation

Attributes:

entity_summary_list: List[EntitySummary]

Array of EntitySummary objects.

next_token: Optional[str]

The value of the next token if it exists. Null if there is no more result.

Resources internal elements

class cloudpub.models.aws.BaseEntity(type, identifier)[source]

Represent an in change entity on AWS.

Attributes:

identifier: str

The identifier of the entity, in the format of EntityId@RevisionId.

type: str

The named type of the entity, in the format of EntityType@Version.

class cloudpub.models.aws.OperatingSystem(name, version, username, scanning_port)[source]

Represent the operating_system attribute of ProductVersionsVirtualizationSource.

Attributes:

name: str

The OS name.

scanning_port: int

The main port used to remotely access the OS.

username: str

The main username to log in into the OS.

version: str

The OS version.

class cloudpub.models.aws.ProductVersionsBase(source_id, type)[source]

The base definition for product versions.

Attributes:

source_id: str

The ID for the current product version.

type: str

The product version type.

Expected value (one of):

  • AmazonMachineImage

  • CloudFormationTemplate

valid_type(attribute, value)[source]

Ensure the attribute type has an expected value.

Return type:

None

class cloudpub.models.aws.ProductVersionsCloudFormationSource(source_id, type, nested_documents, consumed_sources, aws_dependent_services, architecture_diagram, template)[source]

Represent one of the supported source types from ProductVersionsResponse.

Attributes:

architecture_diagram: Optional[str]

The architecture diagram of the current CloudFormation source.

aws_dependent_services: List[str]

The dependent services for the current CloudFormation source.

consumed_sources: List[str]

The consumed sources for the current CloudFormation source.

nested_documents: Optional[List[str]]

List of nested documents for the current CloudFormation source.

template: Optional[str]

The CloudFormation’s template.

class cloudpub.models.aws.ProductVersionsVirtualizationSource(source_id, type, image, architecture, virtualization_type, operating_system, compatibility)[source]

Represent one of the supported source types from ProductVersionsResponse.

Attributes:

architecture: str

The VM architecture for the virtualization source.

compatibility: SourcesCompatibility

The source compatibilities for the current version.

image: str

The AMI for the virtualization source.

operating_system: OperatingSystem

The operating system for the current version.

virtualization_type: str

The virtualization type.

Expected value (one of):

  • hvm

  • pv

class cloudpub.models.aws.SourcesCompatibility(available_instance_types, restricted_instance_types)[source]

Represent the compatibility attribute of ProductVersionsVirtualizationSource.

Attributes:

available_instance_types: List[str]

The instance types supported by the current VM.

restricted_instance_types: List[str]

The restricted instance types for the current VM.

class cloudpub.models.aws.BaseResources(type, url)[source]

Common base class for extra resources.

Child classes:

Attributes:

type: Literal['Link']

The extra resource type.

url: str

The extra resource URL.

class cloudpub.models.aws.AdditionalResources(type, url, text)[source]

Represent a single element of additional_resources from class PromotionalResources.

Attributes:

  • type() [inherited]

  • url() [inherited]

  • text()

text: str

The additional resource text.

class cloudpub.models.aws.PromoResourcesVideo(type, url, title)[source]

Represent a single element of videos from class PromotionalResources.

Attributes:

  • type() [inherited]

  • url() [inherited]

  • title()

title: str

The promotional video title.

class cloudpub.models.aws.PositiveTargeting(buyer_accounts)[source]

Represent the positive_targeting attribute of TargetingDetail.

Attributes:

buyer_accounts: Optional[List[str]]

List of buyer accounts.

class cloudpub.models.aws.ResponseMetadata(request_id, status_code, http_headers, retry_attemps)[source]

Represent the describe_entity HTTPS response metadata.

It’s part of DescribeEntityResponse.

Attributes:

http_headers: Dict[str, str]

The HTTP readers returned in the response.

Fields:

  • date: The HTTP response date (e.g.: “Fri, 25 Aug 2023 20:50:06 GMT”)

  • content-type: The HTTP content type (e.g: “application/json”)

# content-length: The HTTP body length (e.g.: “3029”) # connection: The HTTP connection definition (e.g.: “keep-alive”) # x-amzn-requestid: The UUID of the request ID to AWS.

request_id: str

The UUID of the request to AWS.

status_code: int

The HTTP status code returned in the response.

class cloudpub.models.aws.ChangeSummary(change_type, entity, details, error_details, name)[source]

Represent a single element of the “change_set” attribute of DescribeChangeSetReponse.

Attributes:

change_type: str

The type of the change.

details: str

This object contains details specific to the change type of the requested change.

entity: BaseEntity

The entity to be changed.

error_details: List[ErrorDetail]

An array of ErrorDetail objects associated with the change.

name: Optional[str]

Optional name for the change.

class cloudpub.models.aws.DescribeChangeSetReponse(id, arn, name, start_time, end_time, status, failure_code, failure_description, change_set)[source]

Represent the response of MarketplaceCatalog.Client.describe_change_set.

Documentation

Attributes:

arn: str

The ARN associated with the unique identifier for the change set referenced in this request.

change_set: List[ChangeSummary]

An array of ChangeSummary objects.

end_time: Optional[str]

22Z) the request transitioned to a terminal state.

The change cannot transition to a different state. Null if the request is not in a terminal state.

Type:

The date and time, in ISO 8601 format (2018-02-27T13

Type:

45

failure_code: Optional[str]

Returned if the change set is in FAILED status.

Can be either CLIENT_ERROR, which means that there are issues with the request (see the ErrorDetailList), or SERVER_FAULT, which means that there is a problem in the system, and you should retry your request.

failure_description: Optional[str]

Returned if there is a failure on the change set, but that failure is not related to any of the changes in the request.

id: str

The unique identifier for the change set referenced in this request.

start_time: str

22Z), the request started.

Type:

The date and time, in ISO 8601 format (2018-02-27T13

Type:

45

status: str

The status of the change request.

Expected value (one of):

  • PREPARING

  • APPLYING

  • SUCCEEDED

  • CANCELLED

  • FAILED

class cloudpub.models.aws.ErrorDetail(code, message)[source]

Represent the details of a single error.

Attributes:

code: str

The error code that identifies the type of error.

message: str

The message for the error.

class cloudpub.models.aws.ChangeSetResponse[source]

Represent the response of MarketplaceCatalog.Client.start_change_set or MarketplaceCatalog.Client.cancel_change_set.

ChangeSetArn: str

The ARN associated with the change set referenced in this request.

ChangeSetId: str

The unique identifier for the change set referenced in this request.

class cloudpub.models.aws.GroupedVersions[source]

Represent a simplified data for versions with fewer information.

ami_ids: List[str]

A list of AMI ids.

created_date: str

The creation date of a specific version.

delivery_options: List[DeliveryOption]

List of DeliveryOption objects of a specific version.