|
| 1 | +# coding: utf-8 |
| 2 | +# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. |
| 3 | +# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. |
| 4 | +# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20241130 |
| 5 | + |
| 6 | +from __future__ import print_function |
| 7 | +import click |
| 8 | +import oci # noqa: F401 |
| 9 | +import six # noqa: F401 |
| 10 | +import sys # noqa: F401 |
| 11 | +from oci_cli import cli_constants # noqa: F401 |
| 12 | +from oci_cli import cli_util |
| 13 | +from oci_cli import json_skeleton_utils |
| 14 | +from oci_cli import custom_types # noqa: F401 |
| 15 | +from oci_cli.aliasing import CommandGroupWithAlias |
| 16 | +from services.apiaccesscontrol.src.oci_cli_apiaccesscontrol.generated import apiaccesscontrol_service_cli |
| 17 | + |
| 18 | + |
| 19 | +@click.command(cli_util.override('api_metadata.api_metadata_root_group.command_name', 'api-metadata'), cls=CommandGroupWithAlias, help=cli_util.override('api_metadata.api_metadata_root_group.help', """This service is used to restrict the control plane service apis; so that everybody won't be |
| 20 | +able to access those apis. |
| 21 | +There are two main resouces defined as a part of this service |
| 22 | +1. PrivilegedApiControl: This is created by the customer which defines which service apis are |
| 23 | + controlled and who can access it. |
| 24 | +2. PrivilegedApiRequest: This is a request object again created by the customer operators who seek access to those privileged apis. After a request is obtained based on the PrivilegedAccessControl for which the api belongs to, either it can be approved so that the requested person can execute the service apis or it will wait for the customer to approve it."""), short_help=cli_util.override('api_metadata.api_metadata_root_group.short_help', """Oracle API Access Control""")) |
| 25 | +@cli_util.help_option_group |
| 26 | +def api_metadata_root_group(): |
| 27 | + pass |
| 28 | + |
| 29 | + |
| 30 | +@click.command(cli_util.override('api_metadata.api_metadata_group.command_name', 'api-metadata'), cls=CommandGroupWithAlias, help="""An ApiDetail contains details such as the service it belongs to, the name of the api, the type of api, and the parameters of the api if it contains. |
| 31 | +
|
| 32 | +To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, talk to an administrator. If you're an administrator who needs to write policies to give users access, see [Getting Started with Policies].""") |
| 33 | +@cli_util.help_option_group |
| 34 | +def api_metadata_group(): |
| 35 | + pass |
| 36 | + |
| 37 | + |
| 38 | +apiaccesscontrol_service_cli.apiaccesscontrol_service_group.add_command(api_metadata_root_group) |
| 39 | +api_metadata_root_group.add_command(api_metadata_group) |
| 40 | + |
| 41 | + |
| 42 | +@api_metadata_group.command(name=cli_util.override('api_metadata.get_api_metadata.command_name', 'get'), help=u"""Gets information about a ApiMetadata. \n[Command Reference](getApiMetadata)""") |
| 43 | +@cli_util.option('--api-metadata-id', required=True, help=u"""The [OCID] of the PrivilegedApiControl.""") |
| 44 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 45 | +@cli_util.help_option |
| 46 | +@click.pass_context |
| 47 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apiaccesscontrol', 'class': 'ApiMetadata'}) |
| 48 | +@cli_util.wrap_exceptions |
| 49 | +def get_api_metadata(ctx, from_json, api_metadata_id): |
| 50 | + |
| 51 | + if isinstance(api_metadata_id, six.string_types) and len(api_metadata_id.strip()) == 0: |
| 52 | + raise click.UsageError('Parameter --api-metadata-id cannot be whitespace or empty string') |
| 53 | + |
| 54 | + kwargs = {} |
| 55 | + kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id']) |
| 56 | + client = cli_util.build_client('apiaccesscontrol', 'api_metadata', ctx) |
| 57 | + result = client.get_api_metadata( |
| 58 | + api_metadata_id=api_metadata_id, |
| 59 | + **kwargs |
| 60 | + ) |
| 61 | + cli_util.render_response(result, ctx) |
| 62 | + |
| 63 | + |
| 64 | +@api_metadata_group.command(name=cli_util.override('api_metadata.list_api_metadata.command_name', 'list'), help=u"""Gets a list of ApiMetadata. \n[Command Reference](listApiMetadata)""") |
| 65 | +@cli_util.option('--compartment-id', help=u"""The [OCID] of the compartment in which to list resources.""") |
| 66 | +@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "UPDATING", "ACTIVE", "DELETING", "DELETED", "FAILED"]), help=u"""A filter to return only resources that match the given lifecycle state. The state value is case-insensitive.""") |
| 67 | +@cli_util.option('--resource-type', help=u"""A filter to return only lists of resources that match the entire given service type.""") |
| 68 | +@cli_util.option('--display-name', help=u"""A filter to return only resources that match the given display name exactly.""") |
| 69 | +@cli_util.option('--limit', type=click.INT, help=u"""For list pagination. The maximum number of results per page, or items to return in a paginated \"List\" call. For important details about how pagination works, see [List Pagination].""") |
| 70 | +@cli_util.option('--page', help=u"""For list pagination. The value of the opc-next-page response header from the previous \"List\" call. For important details about how pagination works, see [List Pagination].""") |
| 71 | +@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either ascending (`ASC`) or descending (`DESC`).""") |
| 72 | +@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName"]), help=u"""The field to sort by. You can provide only one sort order. Default order for `timeCreated` is descending. Default order for `displayName` is ascending.""") |
| 73 | +@cli_util.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") |
| 74 | +@cli_util.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") |
| 75 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 76 | +@cli_util.help_option |
| 77 | +@click.pass_context |
| 78 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apiaccesscontrol', 'class': 'ApiMetadataCollection'}) |
| 79 | +@cli_util.wrap_exceptions |
| 80 | +def list_api_metadata(ctx, from_json, all_pages, page_size, compartment_id, lifecycle_state, resource_type, display_name, limit, page, sort_order, sort_by): |
| 81 | + |
| 82 | + if all_pages and limit: |
| 83 | + raise click.UsageError('If you provide the --all option you cannot provide the --limit option') |
| 84 | + |
| 85 | + kwargs = {} |
| 86 | + if compartment_id is not None: |
| 87 | + kwargs['compartment_id'] = compartment_id |
| 88 | + if lifecycle_state is not None: |
| 89 | + kwargs['lifecycle_state'] = lifecycle_state |
| 90 | + if resource_type is not None: |
| 91 | + kwargs['resource_type'] = resource_type |
| 92 | + if display_name is not None: |
| 93 | + kwargs['display_name'] = display_name |
| 94 | + if limit is not None: |
| 95 | + kwargs['limit'] = limit |
| 96 | + if page is not None: |
| 97 | + kwargs['page'] = page |
| 98 | + if sort_order is not None: |
| 99 | + kwargs['sort_order'] = sort_order |
| 100 | + if sort_by is not None: |
| 101 | + kwargs['sort_by'] = sort_by |
| 102 | + kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id']) |
| 103 | + client = cli_util.build_client('apiaccesscontrol', 'api_metadata', ctx) |
| 104 | + if all_pages: |
| 105 | + if page_size: |
| 106 | + kwargs['limit'] = page_size |
| 107 | + |
| 108 | + result = cli_util.list_call_get_all_results( |
| 109 | + client.list_api_metadata, |
| 110 | + **kwargs |
| 111 | + ) |
| 112 | + elif limit is not None: |
| 113 | + result = cli_util.list_call_get_up_to_limit( |
| 114 | + client.list_api_metadata, |
| 115 | + limit, |
| 116 | + page_size, |
| 117 | + **kwargs |
| 118 | + ) |
| 119 | + else: |
| 120 | + result = client.list_api_metadata( |
| 121 | + **kwargs |
| 122 | + ) |
| 123 | + cli_util.render_response(result, ctx) |
| 124 | + |
| 125 | + |
| 126 | +@api_metadata_group.command(name=cli_util.override('api_metadata.list_api_metadata_by_entity_types.command_name', 'list-api-metadata-by-entity-types'), help=u"""Gets a list of ApiMetadata Grouped By Entity Types. \n[Command Reference](listApiMetadataByEntityTypes)""") |
| 127 | +@cli_util.option('--compartment-id', help=u"""The [OCID] of the compartment in which to list resources.""") |
| 128 | +@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "UPDATING", "ACTIVE", "DELETING", "DELETED", "FAILED"]), help=u"""A filter to return only resources that match the given lifecycle state. The state value is case-insensitive.""") |
| 129 | +@cli_util.option('--resource-type', help=u"""A filter to return only lists of resources that match the entire given service type.""") |
| 130 | +@cli_util.option('--display-name', help=u"""A filter to return only resources that match the given display name exactly.""") |
| 131 | +@cli_util.option('--limit', type=click.INT, help=u"""For list pagination. The maximum number of results per page, or items to return in a paginated \"List\" call. For important details about how pagination works, see [List Pagination].""") |
| 132 | +@cli_util.option('--page', help=u"""For list pagination. The value of the opc-next-page response header from the previous \"List\" call. For important details about how pagination works, see [List Pagination].""") |
| 133 | +@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either ascending (`ASC`) or descending (`DESC`).""") |
| 134 | +@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName"]), help=u"""The field to sort by. You can provide only one sort order. Default order for `timeCreated` is descending. Default order for `displayName` is ascending.""") |
| 135 | +@cli_util.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""") |
| 136 | +@cli_util.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""") |
| 137 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 138 | +@cli_util.help_option |
| 139 | +@click.pass_context |
| 140 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apiaccesscontrol', 'class': 'ApiMetadataByEntityTypeCollection'}) |
| 141 | +@cli_util.wrap_exceptions |
| 142 | +def list_api_metadata_by_entity_types(ctx, from_json, all_pages, page_size, compartment_id, lifecycle_state, resource_type, display_name, limit, page, sort_order, sort_by): |
| 143 | + |
| 144 | + if all_pages and limit: |
| 145 | + raise click.UsageError('If you provide the --all option you cannot provide the --limit option') |
| 146 | + |
| 147 | + kwargs = {} |
| 148 | + if compartment_id is not None: |
| 149 | + kwargs['compartment_id'] = compartment_id |
| 150 | + if lifecycle_state is not None: |
| 151 | + kwargs['lifecycle_state'] = lifecycle_state |
| 152 | + if resource_type is not None: |
| 153 | + kwargs['resource_type'] = resource_type |
| 154 | + if display_name is not None: |
| 155 | + kwargs['display_name'] = display_name |
| 156 | + if limit is not None: |
| 157 | + kwargs['limit'] = limit |
| 158 | + if page is not None: |
| 159 | + kwargs['page'] = page |
| 160 | + if sort_order is not None: |
| 161 | + kwargs['sort_order'] = sort_order |
| 162 | + if sort_by is not None: |
| 163 | + kwargs['sort_by'] = sort_by |
| 164 | + kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id']) |
| 165 | + client = cli_util.build_client('apiaccesscontrol', 'api_metadata', ctx) |
| 166 | + if all_pages: |
| 167 | + if page_size: |
| 168 | + kwargs['limit'] = page_size |
| 169 | + |
| 170 | + result = cli_util.list_call_get_all_results( |
| 171 | + client.list_api_metadata_by_entity_types, |
| 172 | + **kwargs |
| 173 | + ) |
| 174 | + elif limit is not None: |
| 175 | + result = cli_util.list_call_get_up_to_limit( |
| 176 | + client.list_api_metadata_by_entity_types, |
| 177 | + limit, |
| 178 | + page_size, |
| 179 | + **kwargs |
| 180 | + ) |
| 181 | + else: |
| 182 | + result = client.list_api_metadata_by_entity_types( |
| 183 | + **kwargs |
| 184 | + ) |
| 185 | + cli_util.render_response(result, ctx) |
0 commit comments