Skip to content

create_grant

create_grant(
    client_token: ClientToken,
    grant_name: String,
    license_arn: Arn,
    principals: PrincipalArnList,
    home_region: String,
    allowed_operations: AllowedOperationList,
    *,
    config_overrides: Optional[LicenseManagerClientConfig] = None,
    tags: Optional[TagList] = None,
    grant_type: Optional[GrantType] = None,
    options: Optional[Options] = None,
) -> CreateGrantResponse

Creates a grant for the specified license. A grant shares the use of license entitlements with a specific Amazon Web Services account, an organization, or an organizational unit (OU). For more information, see Granted licenses in License Manager in the License Manager User Guide.

Set the type of grant with the GrantType field:

  • BuyerGrant - The default grant type, created by the seller when a customer subscribes to a product. The seller creates a license for the subscription and a buyer grant for the customer. With a buyer grant, the customer can use, consume, and distribute the license, according to the permissions the seller sets in the product contract.

  • DelegateGrant - A delegate grant gives the grantee read-only visibility into the licenses and grants that you have distributed to buyers for a product. The grantee can monitor that activity on your behalf, and can also listen for the related Amazon EventBridge events. A delegate grant conveys no entitlement to use the licenses, and its only allowed operation is ListReceivedLicenses. You must create the delegate grant, and its license, from the same Amazon Web Services account that you used to create those buyer licenses and grants.

Parameters:

  • client_token (ClientToken) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

  • grant_name (String) –

    Grant name.

  • license_arn (Arn) –

    Amazon Resource Name (ARN) of the license.

  • principals (PrincipalArnList) –

    The grant principals. You can specify one of the following as an Amazon Resource Name (ARN):

    • An Amazon Web Services account, which includes only the account specified.

    • An organizational unit (OU), which includes all accounts in the OU.

    • An organization, which will include all accounts across your organization.

  • home_region (String) –

    Home Region of the grant.

  • allowed_operations (AllowedOperationList) –

    Allowed operations for the grant.

  • tags (Optional[TagList], default: None ) –

    Tags to add to the grant. For more information about tagging support in License Manager, see the TagResource operation.

  • grant_type (Optional[GrantType], default: None ) –

    The type of grant to create. For more information about each type, see the preceding description of this operation. Valid values:

    • BuyerGrant - The default grant type if you don't specify a value. Conveys the entitlement to use the license.

    • DelegateGrant - Gives the grantee read-only visibility into the licenses and grants that you have distributed to buyers, with no entitlement to use them.

  • options (Optional[Options], default: None ) –

    The options for the grant: the status to set after creation, and how activating the grant affects other active grants for the same product.

Raises:

Source code in docs_src/capo_license_manager/_services/license_manager.py
def create_grant(
    self,
    client_token: "capo_license_manager.types.client_token.ClientToken",
    grant_name: "capo_license_manager.types.string.String",
    license_arn: "capo_license_manager.types.arn.Arn",
    principals: "capo_license_manager.types.principal_arn_list.PrincipalArnList",
    home_region: "capo_license_manager.types.string.String",
    allowed_operations: "capo_license_manager.types.allowed_operation_list.AllowedOperationList",
    *,
    config_overrides: Optional[LicenseManagerClientConfig] = None,
    tags: Optional["capo_license_manager.types.tag_list.TagList"] = None,
    grant_type: Optional["capo_license_manager.types.grant_type.GrantType"] = None,
    options: Optional["capo_license_manager.types.options.Options"] = None,
) -> "capo_license_manager.types.create_grant_response.CreateGrantResponse":
    """<p>Creates a grant for the specified license. A grant shares the use of license entitlements with a specific Amazon Web Services account, an organization, or an organizational unit (OU). For more information, see <a href="https://docs.aws.amazon.com/license-manager/latest/userguide/granted-licenses.html">Granted licenses in License Manager</a> in the <i>License Manager User Guide</i>.</p> <p>Set the type of grant with the <code>GrantType</code> field:</p> <ul> <li> <p> <code>BuyerGrant</code> - The default grant type, created by the seller when a customer subscribes to a product. The seller creates a license for the subscription and a buyer grant for the customer. With a buyer grant, the customer can use, consume, and distribute the license, according to the permissions the seller sets in the product contract.</p> </li> <li> <p> <code>DelegateGrant</code> - A delegate grant gives the grantee read-only visibility into the licenses and grants that you have distributed to buyers for a product. The grantee can monitor that activity on your behalf, and can also listen for the related Amazon EventBridge events. A delegate grant conveys no entitlement to use the licenses, and its only allowed operation is <code>ListReceivedLicenses</code>. You must create the delegate grant, and its license, from the same Amazon Web Services account that you used to create those buyer licenses and grants.</p> </li> </ul>

    Args:
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
        grant_name: <p>Grant name.</p>
        license_arn: <p>Amazon Resource Name (ARN) of the license.</p>
        principals: <p>The grant principals. You can specify one of the following as an Amazon Resource Name (ARN):</p> <ul> <li> <p>An Amazon Web Services account, which includes only the account specified.</p> </li> </ul> <ul> <li> <p>An organizational unit (OU), which includes all accounts in the OU.</p> </li> </ul> <ul> <li> <p>An organization, which will include all accounts across your organization.</p> </li> </ul>
        home_region: <p>Home Region of the grant.</p>
        allowed_operations: <p>Allowed operations for the grant.</p>
        tags: <p>Tags to add to the grant. For more information about tagging support in License Manager, see the <a href="https://docs.aws.amazon.com/license-manager/latest/APIReference/API_TagResource.html">TagResource</a> operation.</p>
        grant_type: <p>The type of grant to create. For more information about each type, see the preceding description of this operation. Valid values:</p> <ul> <li> <p> <code>BuyerGrant</code> - The default grant type if you don't specify a value. Conveys the entitlement to use the license.</p> </li> <li> <p> <code>DelegateGrant</code> - Gives the grantee read-only visibility into the licenses and grants that you have distributed to buyers, with no entitlement to use them.</p> </li> </ul>
        options: <p>The options for the grant: the status to set after creation, and how activating the grant affects other active grants for the same product.</p>

    Raises:
        capo_license_manager.errors.access_denied_exception.AccessDeniedException: <p>Access to resource denied.</p>
        capo_license_manager.errors.authorization_exception.AuthorizationException: <p>The Amazon Web Services user account does not have permission to perform the action. Check the IAM policy associated with this account.</p>
        capo_license_manager.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One or more parameter values are not valid.</p>
        capo_license_manager.errors.rate_limit_exceeded_exception.RateLimitExceededException: <p>Too many requests have been submitted. Try again after a brief wait.</p>
        capo_license_manager.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>Your resource limits have been exceeded.</p>
        capo_license_manager.errors.server_internal_exception.ServerInternalException: <p>The server experienced an internal error. Try again.</p>
        capo_license_manager.errors.validation_exception.ValidationException: <p>The provided input is not valid. Try your request again.</p>
        capo_license_manager.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_license_manager.types.create_grant_request.CreateGrantRequest]",
    ) -> OperationResponse[
        "capo_license_manager.types.create_grant_response.CreateGrantResponse"
    ]:
        import capo_license_manager._operations.aws_license_manager.create_grant

        output, http_response = (
            capo_license_manager._operations.aws_license_manager.create_grant.create_grant(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateGrant")
    )
    input_: capo_license_manager.types.create_grant_request.CreateGrantRequest = {
        "client_token": client_token,
        "grant_name": grant_name,
        "license_arn": license_arn,
        "principals": principals,
        "home_region": home_region,
        "allowed_operations": allowed_operations,
    }
    if tags is not None:
        input_["tags"] = tags
    if grant_type is not None:
        input_["grant_type"] = grant_type
    if options is not None:
        input_["options"] = options

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output