Skip to content

create_view async

create_view(
    view_name: ViewName,
    *,
    config_overrides: Optional[AsyncResourceExplorer2ClientConfig] = None,
    client_token: Optional[str] = None,
    included_properties: Optional[IncludedPropertyList] = None,
    scope: Optional[str] = None,
    filters: Optional[SearchFilter] = None,
    tags: Optional[TagMap] = None,
) -> CreateViewOutput

Creates a view that users can query by using the Search operation. Results from queries that you make using this view include only resources that match the view's Filters. For more information about Amazon Web Services Resource Explorer views, see Managing views in the Amazon Web Services Resource Explorer User Guide.

Only the principals with an IAM identity-based policy that grants Allow to the Search action on a Resource with the Amazon resource name (ARN) of this view can Search using views you create with this operation.

Parameters:

  • client_token (Optional[str], default: None ) –

    This value helps ensure idempotency. Resource Explorer uses this value to prevent the accidental creation of duplicate versions. We recommend that you generate a UUID-type value to ensure the uniqueness of your views.

  • view_name (ViewName) –

    The name of the new view. This name appears in the list of views in Resource Explorer.

    The name must be no more than 64 characters long, and can include letters, digits, and the dash (-) character. The name must be unique within its Amazon Web Services Region.

  • included_properties (Optional[IncludedPropertyList], default: None ) –

    Specifies optional fields that you want included in search results from this view. It is a list of objects that each describe a field to include.

    The default is an empty list, with no optional fields included in the results.

  • scope (Optional[str], default: None ) –

    The root ARN of the account, an organizational unit (OU), or an organization ARN. If left empty, the default is account.

  • filters (Optional[SearchFilter], default: None ) –

    An array of strings that specify which resources are included in the results of queries made using this view. When you use this view in a Search operation, the filter string is combined with the search's QueryString parameter using a logical AND operator.

    For information about the supported syntax, see Search query reference for Resource Explorer in the Amazon Web Services Resource Explorer User Guide.

    This query string in the context of this operation supports only filter prefixes with optional operators. It doesn't support free-form text. For example, the string region:us* service:ec2 -tag:stage=prod includes all Amazon EC2 resources in any Amazon Web Services Region that begins with the letters us and is not tagged with a key Stage that has the value prod.

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

    Tag key and value pairs that are attached to the view.

Raises:

  • AccessDeniedException –

    The credentials that you used to call this operation don't have the minimum required permissions.

  • ConflictException –

    If you attempted to create a view, then the request failed because either you specified parameters that didn’t match the original request, or you attempted to create a view with a name that already exists in this Amazon Web Services Region.

    If you attempted to create an index, then the request failed because either you specified parameters that didn't match the original request, or an index already exists in the current Amazon Web Services Region.

    If you attempted to update an index type to AGGREGATOR, then the request failed because you already have an AGGREGATOR index in a different Amazon Web Services Region.

  • InternalServerException –

    The request failed because of internal service error. Try your request again later.

  • ServiceQuotaExceededException –

    The request failed because it exceeds a service quota.

  • ThrottlingException –

    The request failed because you exceeded a rate limit for this operation. For more information, see Quotas for Resource Explorer.

  • UnauthorizedException –

    The principal making the request isn't permitted to perform the operation.

  • ValidationException –

    You provided an invalid value for one of the operation's parameters. Check the syntax for the operation, and try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_resource_explorer_2/_services/async_resource_explorer2.py
async def create_view(
    self,
    view_name: "capo_resource_explorer_2.types.view_name.ViewName",
    *,
    config_overrides: Optional[AsyncResourceExplorer2ClientConfig] = None,
    client_token: Optional[str] = None,
    included_properties: Optional[
        "capo_resource_explorer_2.types.included_property_list.IncludedPropertyList"
    ] = None,
    scope: Optional[str] = None,
    filters: Optional[
        "capo_resource_explorer_2.types.search_filter.SearchFilter"
    ] = None,
    tags: Optional["capo_resource_explorer_2.types.tag_map.TagMap"] = None,
) -> "capo_resource_explorer_2.types.create_view_output.CreateViewOutput":
    """<p>Creates a view that users can query by using the <a>Search</a> operation. Results from queries that you make using this view include only resources that match the view's <code>Filters</code>. For more information about Amazon Web Services Resource Explorer views, see <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/manage-views.html">Managing views</a> in the <i>Amazon Web Services Resource Explorer User Guide</i>.</p> <p>Only the principals with an IAM identity-based policy that grants <code>Allow</code> to the <code>Search</code> action on a <code>Resource</code> with the <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon resource name (ARN)</a> of this view can <a>Search</a> using views you create with this operation.</p>

    Args:
        client_token: <p>This value helps ensure idempotency. Resource Explorer uses this value to prevent the accidental creation of duplicate versions. We recommend that you generate a <a href="https://wikipedia.org/wiki/Universally_unique_identifier">UUID-type value</a> to ensure the uniqueness of your views.</p>
        view_name: <p>The name of the new view. This name appears in the list of views in Resource Explorer.</p> <p>The name must be no more than 64 characters long, and can include letters, digits, and the dash (-) character. The name must be unique within its Amazon Web Services Region.</p>
        included_properties: <p>Specifies optional fields that you want included in search results from this view. It is a list of objects that each describe a field to include.</p> <p>The default is an empty list, with no optional fields included in the results.</p>
        scope: <p>The root ARN of the account, an organizational unit (OU), or an organization ARN. If left empty, the default is account.</p>
        filters: <p>An array of strings that specify which resources are included in the results of queries made using this view. When you use this view in a <a>Search</a> operation, the filter string is combined with the search's <code>QueryString</code> parameter using a logical <code>AND</code> operator.</p> <p>For information about the supported syntax, see <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/using-search-query-syntax.html">Search query reference for Resource Explorer</a> in the <i>Amazon Web Services Resource Explorer User Guide</i>.</p> <important> <p>This query string in the context of this operation supports only <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/using-search-query-syntax.html#query-syntax-filters">filter prefixes</a> with optional <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/using-search-query-syntax.html#query-syntax-operators">operators</a>. It doesn't support free-form text. For example, the string <code>region:us* service:ec2 -tag:stage=prod</code> includes all Amazon EC2 resources in any Amazon Web Services Region that begins with the letters <code>us</code> and is <i>not</i> tagged with a key <code>Stage</code> that has the value <code>prod</code>.</p> </important>
        tags: <p>Tag key and value pairs that are attached to the view.</p>

    Raises:
        capo_resource_explorer_2.errors.access_denied_exception.AccessDeniedException: <p>The credentials that you used to call this operation don't have the minimum required permissions.</p>
        capo_resource_explorer_2.errors.conflict_exception.ConflictException: <p>If you attempted to create a view, then the request failed because either you specified parameters that didn’t match the original request, or you attempted to create a view with a name that already exists in this Amazon Web Services Region.</p> <p>If you attempted to create an index, then the request failed because either you specified parameters that didn't match the original request, or an index already exists in the current Amazon Web Services Region.</p> <p>If you attempted to update an index type to <code>AGGREGATOR</code>, then the request failed because you already have an <code>AGGREGATOR</code> index in a different Amazon Web Services Region.</p>
        capo_resource_explorer_2.errors.internal_server_exception.InternalServerException: <p>The request failed because of internal service error. Try your request again later.</p>
        capo_resource_explorer_2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request failed because it exceeds a service quota.</p>
        capo_resource_explorer_2.errors.throttling_exception.ThrottlingException: <p>The request failed because you exceeded a rate limit for this operation. For more information, see <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/quotas.html">Quotas for Resource Explorer</a>.</p>
        capo_resource_explorer_2.errors.unauthorized_exception.UnauthorizedException: <p>The principal making the request isn't permitted to perform the operation.</p>
        capo_resource_explorer_2.errors.validation_exception.ValidationException: <p>You provided an invalid value for one of the operation's parameters. Check the syntax for the operation, and try again.</p>
        capo_resource_explorer_2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_resource_explorer_2.types.create_view_input.CreateViewInput]",
    ) -> AsyncOperationResponse[
        "capo_resource_explorer_2.types.create_view_output.CreateViewOutput"
    ]:
        import capo_resource_explorer_2._operations.resource_explorer.create_view

        (
            output,
            http_response,
        ) = await capo_resource_explorer_2._operations.resource_explorer.create_view.async_create_view(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_resource_explorer_2.types.create_view_input.CreateViewInput",
    ) -> dict[str, Any]:
        import capo_resource_explorer_2.types.create_view_input

        return capo_resource_explorer_2.types.create_view_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_resource_explorer_2.types.create_view_output.CreateViewOutput",
    ) -> dict[str, Any]:
        import capo_resource_explorer_2.types.create_view_output

        return capo_resource_explorer_2.types.create_view_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateView", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_resource_explorer_2.types.create_view_input.CreateViewInput = {
        "view_name": view_name
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if included_properties is not None:
        input_["included_properties"] = included_properties
    if scope is not None:
        input_["scope"] = scope
    if filters is not None:
        input_["filters"] = filters
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output