Skip to content

create_code_review async

create_code_review(
    title: str,
    agent_space_id: str,
    assets: Assets,
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    service_role: Optional[ServiceRole] = None,
    log_config: Optional[CloudWatchLog] = None,
    code_remediation_strategy: Optional[CodeRemediationStrategy] = None,
    validation_mode: Optional[ValidationMode] = None,
    max_task_hours: Optional[float] = None,
    report_destination: Optional[ReportDestination] = None,
    report_filters: Optional[ReportFilters] = None,
) -> CreateCodeReviewOutput

Creates a new code review configuration in an agent space. A code review defines the parameters for automated security-focused code analysis.

Parameters:

  • title (str) –

    The title of the code review.

  • agent_space_id (str) –

    The unique identifier of the agent space to create the code review in.

  • assets (Assets) –

    The assets to include in the code review, such as documents and source code.

  • service_role (Optional[ServiceRole], default: None ) –

    The IAM service role to use for the code review.

  • log_config (Optional[CloudWatchLog], default: None ) –

    The CloudWatch Logs configuration for the code review.

  • code_remediation_strategy (Optional[CodeRemediationStrategy], default: None ) –

    The code remediation strategy for the code review. Valid values are AUTOMATIC and DISABLED.

  • validation_mode (Optional[ValidationMode], default: None ) –

    The validation mode for the code review. Valid values are SIMULATED and DISABLED.

  • max_task_hours (Optional[float], default: None ) –

    The maximum number of billable task hours allowed for jobs started from this code review. Must be a positive number. If not set, jobs run to completion with no budget cap.

  • report_destination (Optional[ReportDestination], default: None ) –

    The destination for publishing scan reports to an integrated document provider.

  • report_filters (Optional[ReportFilters], default: None ) –

    The report-generation filters applied when the report is exported.

Raises:

Source code in docs_src/capo_securityagent/_services/async_security_agent.py
async def create_code_review(
    self,
    title: str,
    agent_space_id: str,
    assets: "capo_securityagent.types.assets.Assets",
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    service_role: Optional[
        "capo_securityagent.types.service_role.ServiceRole"
    ] = None,
    log_config: Optional[
        "capo_securityagent.types.cloud_watch_log.CloudWatchLog"
    ] = None,
    code_remediation_strategy: Optional[
        "capo_securityagent.types.code_remediation_strategy.CodeRemediationStrategy"
    ] = None,
    validation_mode: Optional[
        "capo_securityagent.types.validation_mode.ValidationMode"
    ] = None,
    max_task_hours: Optional[float] = None,
    report_destination: Optional[
        "capo_securityagent.types.report_destination.ReportDestination"
    ] = None,
    report_filters: Optional[
        "capo_securityagent.types.report_filters.ReportFilters"
    ] = None,
) -> "capo_securityagent.types.create_code_review_output.CreateCodeReviewOutput":
    """<p>Creates a new code review configuration in an agent space. A code review defines the parameters for automated security-focused code analysis.</p>

    Args:
        title: <p>The title of the code review.</p>
        agent_space_id: <p>The unique identifier of the agent space to create the code review in.</p>
        assets: <p>The assets to include in the code review, such as documents and source code.</p>
        service_role: <p>The IAM service role to use for the code review.</p>
        log_config: <p>The CloudWatch Logs configuration for the code review.</p>
        code_remediation_strategy: <p>The code remediation strategy for the code review. Valid values are AUTOMATIC and DISABLED.</p>
        validation_mode: <p>The validation mode for the code review. Valid values are SIMULATED and DISABLED.</p>
        max_task_hours: <p>The maximum number of billable task hours allowed for jobs started from this code review. Must be a positive number. If not set, jobs run to completion with no budget cap.</p>
        report_destination: <p>The destination for publishing scan reports to an integrated document provider.</p>
        report_filters: <p>The report-generation filters applied when the report is exported.</p>

    Raises:
        capo_securityagent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityagent.types.create_code_review_input.CreateCodeReviewInput]",
    ) -> AsyncOperationResponse[
        "capo_securityagent.types.create_code_review_output.CreateCodeReviewOutput"
    ]:
        import capo_securityagent._operations.security_agent.create_code_review

        (
            output,
            http_response,
        ) = await capo_securityagent._operations.security_agent.create_code_review.async_create_code_review(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_securityagent.types.create_code_review_input.CreateCodeReviewInput",
    ) -> dict[str, Any]:
        import capo_securityagent.types.create_code_review_input

        return capo_securityagent.types.create_code_review_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_securityagent.types.create_code_review_output.CreateCodeReviewOutput",
    ) -> dict[str, Any]:
        import capo_securityagent.types.create_code_review_output

        return capo_securityagent.types.create_code_review_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateCodeReview",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_securityagent.types.create_code_review_input.CreateCodeReviewInput = {
        "title": title,
        "agent_space_id": agent_space_id,
        "assets": assets,
    }
    if service_role is not None:
        input_["service_role"] = service_role
    if log_config is not None:
        input_["log_config"] = log_config
    if code_remediation_strategy is not None:
        input_["code_remediation_strategy"] = code_remediation_strategy
    if validation_mode is not None:
        input_["validation_mode"] = validation_mode
    if max_task_hours is not None:
        input_["max_task_hours"] = max_task_hours
    if report_destination is not None:
        input_["report_destination"] = report_destination
    if report_filters is not None:
        input_["report_filters"] = report_filters

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