|
| 1 | +# coding: utf-8 |
| 2 | +# Copyright (c) 2022, 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 | + |
| 5 | +from oci_cli import cli_util |
| 6 | +from services.compute_cloud_at_customer.src.oci_cli_compute_cloud_at_customer.generated \ |
| 7 | + import computecloudatcustomer_cli |
| 8 | +from oci_cli import json_skeleton_utils |
| 9 | +import click |
| 10 | + |
| 11 | + |
| 12 | +# Update the intermediate commands to remove the prefix ccc- (duplicated information) |
| 13 | +cli_util.rename_command(computecloudatcustomer_cli, computecloudatcustomer_cli.ccc_root_group, |
| 14 | + computecloudatcustomer_cli.ccc_infrastructure_group, "infrastructure") |
| 15 | +cli_util.rename_command(computecloudatcustomer_cli, computecloudatcustomer_cli.ccc_root_group, |
| 16 | + computecloudatcustomer_cli.ccc_upgrade_schedule_group, "upgrade-schedule") |
| 17 | + |
| 18 | +# Update sub-commands to remove redundant 'ccc', these have to come before the moves |
| 19 | +cli_util.rename_command(computecloudatcustomer_cli, computecloudatcustomer_cli.ccc_infrastructure_collection_group, |
| 20 | + computecloudatcustomer_cli.list_ccc_infrastructures, "list") |
| 21 | +cli_util.rename_command(computecloudatcustomer_cli, computecloudatcustomer_cli.ccc_upgrade_schedule_collection_group, |
| 22 | + computecloudatcustomer_cli.list_ccc_upgrade_schedules, "list") |
| 23 | + |
| 24 | +# Move the -collection commands over to the simple roots (upgrade-schedule and infrastructure) |
| 25 | +computecloudatcustomer_cli.ccc_root_group.commands.pop( |
| 26 | + computecloudatcustomer_cli.ccc_upgrade_schedule_collection_group.name) |
| 27 | +computecloudatcustomer_cli.ccc_root_group.commands.pop( |
| 28 | + computecloudatcustomer_cli.ccc_infrastructure_collection_group.name) |
| 29 | +computecloudatcustomer_cli.ccc_upgrade_schedule_group.add_command(computecloudatcustomer_cli.list_ccc_upgrade_schedules) |
| 30 | +computecloudatcustomer_cli.ccc_infrastructure_group.add_command(computecloudatcustomer_cli.list_ccc_infrastructures) |
| 31 | + |
| 32 | + |
| 33 | +# Update the parameters to remove the prefix ccc- (duplicated information) |
| 34 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.create_ccc_infrastructure, |
| 35 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 36 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 37 | + name=cli_util.override('create_ccc_infrastructure.command_name', 'create'), |
| 38 | + help="""Creates a Compute Cloud@Customer infrastructure. Once created, Oracle Services must connect the rack in the data center to this Oracle Cloud Infrastructure resource.""") |
| 39 | +@cli_util.option('--upgrade-schedule-id', required=False, |
| 40 | + help=u"""Schedule used for upgrades. If no schedule is associated with the infrastructure, it can be updated at any time.""") |
| 41 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 42 | +@click.pass_context |
| 43 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, string)'}}) |
| 44 | +@cli_util.wrap_exceptions |
| 45 | +def create_ccc_infrastructure(ctx, **kwargs): |
| 46 | + if 'upgrade_schedule_id' in kwargs: |
| 47 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 48 | + kwargs.pop('upgrade_schedule_id') |
| 49 | + ctx.invoke(computecloudatcustomer_cli.create_ccc_infrastructure, **kwargs) |
| 50 | + |
| 51 | + |
| 52 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.update_ccc_infrastructure, |
| 53 | + params_to_exclude=['ccc_infrastructure_id', |
| 54 | + 'ccc_upgrade_schedule_id']) |
| 55 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 56 | + name=cli_util.override('update_ccc_infrastructure.command_name', 'update'), |
| 57 | + help="""Updates Compute Cloud@Customer infrastructure resource.""") |
| 58 | +@cli_util.option('--infrastructure-id', required=True, |
| 59 | + help=u"""An OCID for a Compute Cloud@Customer Infrastructure.""") |
| 60 | +@cli_util.option('--upgrade-schedule-id', required=False, |
| 61 | + help=u"""Schedule used for upgrades. If no schedule is associated with the infrastructure, it can be updated at any time.""") |
| 62 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 63 | +@click.pass_context |
| 64 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, string)'}}) |
| 65 | +@cli_util.wrap_exceptions |
| 66 | +def update_ccc_infrastructure(ctx, **kwargs): |
| 67 | + if 'infrastructure_id' in kwargs: |
| 68 | + kwargs['ccc_infrastructure_id'] = kwargs['infrastructure_id'] |
| 69 | + kwargs.pop('infrastructure_id') |
| 70 | + if 'upgrade_schedule_id' in kwargs: |
| 71 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 72 | + kwargs.pop('upgrade_schedule_id') |
| 73 | + ctx.invoke(computecloudatcustomer_cli.update_ccc_infrastructure, **kwargs) |
| 74 | + |
| 75 | + |
| 76 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.get_ccc_infrastructure, |
| 77 | + params_to_exclude=['ccc_infrastructure_id']) |
| 78 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 79 | + name=cli_util.override('get_ccc_infrastructure.command_name', 'get'), |
| 80 | + help="""Gets a Compute Cloud@Customer infrastructure.""") |
| 81 | +@cli_util.option('--infrastructure-id', required=True, |
| 82 | + help=u"""An OCID for a Compute Cloud@Customer Infrastructure.""") |
| 83 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 84 | +@click.pass_context |
| 85 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 86 | +@cli_util.wrap_exceptions |
| 87 | +def get_ccc_infrastructure(ctx, **kwargs): |
| 88 | + if 'infrastructure_id' in kwargs: |
| 89 | + kwargs['ccc_infrastructure_id'] = kwargs['infrastructure_id'] |
| 90 | + kwargs.pop('infrastructure_id') |
| 91 | + ctx.invoke(computecloudatcustomer_cli.get_ccc_infrastructure, **kwargs) |
| 92 | + |
| 93 | + |
| 94 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.delete_ccc_infrastructure, |
| 95 | + params_to_exclude=['ccc_infrastructure_id']) |
| 96 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 97 | + name=cli_util.override('delete_ccc_infrastructure.command_name', 'delete'), |
| 98 | + help="""Deletes a Compute Cloud@Customer infrastructure resource specified by the resource OCID.""") |
| 99 | +@cli_util.option('--infrastructure-id', required=True, |
| 100 | + help=u"""An OCID for a Compute Cloud@Customer Infrastructure.""") |
| 101 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 102 | +@click.pass_context |
| 103 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 104 | +@cli_util.wrap_exceptions |
| 105 | +def delete_ccc_infrastructure(ctx, **kwargs): |
| 106 | + if 'infrastructure_id' in kwargs: |
| 107 | + kwargs['ccc_infrastructure_id'] = kwargs['infrastructure_id'] |
| 108 | + kwargs.pop('infrastructure_id') |
| 109 | + ctx.invoke(computecloudatcustomer_cli.delete_ccc_infrastructure, **kwargs) |
| 110 | + |
| 111 | + |
| 112 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.change_ccc_infrastructure_compartment, |
| 113 | + params_to_exclude=['ccc_infrastructure_id']) |
| 114 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 115 | + name=cli_util.override('change_ccc_infrastructure_compartment.command_name', 'change-compartment'), |
| 116 | + help="""Moves a Compute Cloud@Customer infrastructure resource from one compartment to another.""") |
| 117 | +@cli_util.option('--infrastructure-id', required=True, |
| 118 | + help=u"""An OCID for a Compute Cloud@Customer Infrastructure.""") |
| 119 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 120 | +@click.pass_context |
| 121 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 122 | +@cli_util.wrap_exceptions |
| 123 | +def change_ccc_infrastructure_compartment(ctx, **kwargs): |
| 124 | + if 'infrastructure_id' in kwargs: |
| 125 | + kwargs['ccc_infrastructure_id'] = kwargs['infrastructure_id'] |
| 126 | + kwargs.pop('infrastructure_id') |
| 127 | + ctx.invoke(computecloudatcustomer_cli.change_ccc_infrastructure_compartment, **kwargs) |
| 128 | + |
| 129 | + |
| 130 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.list_ccc_infrastructures, |
| 131 | + params_to_exclude=['ccc_infrastructure_id']) |
| 132 | +@computecloudatcustomer_cli.ccc_infrastructure_group.command( |
| 133 | + name=cli_util.override('list_ccc_infrastructure.command_name', 'list'), |
| 134 | + help="""Returns a list of Compute Cloud@Customer infrastructures.""") |
| 135 | +@cli_util.option('--infrastructure-id', required=False, |
| 136 | + help=u"""An OCID for a Compute Cloud@Customer Infrastructure.""") |
| 137 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 138 | +@click.pass_context |
| 139 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, string)'}}) |
| 140 | +@cli_util.wrap_exceptions |
| 141 | +def list_ccc_infrastructure(ctx, **kwargs): |
| 142 | + if 'infrastructure_id' in kwargs: |
| 143 | + kwargs['ccc_infrastructure_id'] = kwargs['infrastructure_id'] |
| 144 | + kwargs.pop('infrastructure_id') |
| 145 | + ctx.invoke(computecloudatcustomer_cli.list_ccc_infrastructures, **kwargs) |
| 146 | + |
| 147 | + |
| 148 | +# Update the parameters to remove the prefix ccc- (duplicated information) |
| 149 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.update_ccc_upgrade_schedule, |
| 150 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 151 | +@computecloudatcustomer_cli.ccc_upgrade_schedule_group.command( |
| 152 | + name=cli_util.override('update_ccc_upgrade_schedule.command_name', 'update'), |
| 153 | + help="""Updates the Compute Cloud@Customer upgrade schedule.""") |
| 154 | +@cli_util.option('--upgrade-schedule-id', required=True, |
| 155 | + help=u"""Compute Cloud@Customer upgrade schedule OCID.""") |
| 156 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 157 | +@click.pass_context |
| 158 | +@json_skeleton_utils.json_skeleton_generation_handler({'events': {'module': 'compute_cloud_at_customer', 'class': 'list[CreateCccScheduleEvent]'}, 'freeform-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'compute_cloud_at_customer', 'class': 'dict(str, dict(str, object))'}}) |
| 159 | +@cli_util.wrap_exceptions |
| 160 | +def update_ccc_upgrade_schedule(ctx, **kwargs): |
| 161 | + if 'upgrade_schedule_id' in kwargs: |
| 162 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 163 | + kwargs.pop('upgrade_schedule_id') |
| 164 | + ctx.invoke(computecloudatcustomer_cli.update_ccc_upgrade_schedule, **kwargs) |
| 165 | + |
| 166 | + |
| 167 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.get_ccc_upgrade_schedule, |
| 168 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 169 | +@computecloudatcustomer_cli.ccc_upgrade_schedule_group.command( |
| 170 | + name=cli_util.override('get_ccc_upgrade_schedule.command_name', 'get'), |
| 171 | + help="""Gets a Compute Cloud@Customer upgrade schedule by the specified OCID.""") |
| 172 | +@cli_util.option('--upgrade-schedule-id', required=True, |
| 173 | + help=u"""Compute Cloud@Customer upgrade schedule OCID.""") |
| 174 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 175 | +@click.pass_context |
| 176 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 177 | +@cli_util.wrap_exceptions |
| 178 | +def get_ccc_upgrade_schedule(ctx, **kwargs): |
| 179 | + if 'upgrade_schedule_id' in kwargs: |
| 180 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 181 | + kwargs.pop('upgrade_schedule_id') |
| 182 | + ctx.invoke(computecloudatcustomer_cli.get_ccc_upgrade_schedule, **kwargs) |
| 183 | + |
| 184 | + |
| 185 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.list_ccc_upgrade_schedules, |
| 186 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 187 | +@computecloudatcustomer_cli.ccc_upgrade_schedule_group.command( |
| 188 | + name=cli_util.override('list_ccc_upgrade_schedules.command_name', 'list'), |
| 189 | + help="""Returns a list of Compute Cloud@Customer upgrade schedules.""") |
| 190 | +@cli_util.option('--upgrade-schedule-id', required=False, |
| 191 | + help=u"""Compute Cloud@Customer upgrade schedule OCID.""") |
| 192 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 193 | +@click.pass_context |
| 194 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 195 | +@cli_util.wrap_exceptions |
| 196 | +def list_ccc_upgrade_schedule(ctx, **kwargs): |
| 197 | + if 'upgrade_schedule_id' in kwargs: |
| 198 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 199 | + kwargs.pop('upgrade_schedule_id') |
| 200 | + ctx.invoke(computecloudatcustomer_cli.list_ccc_upgrade_schedules, **kwargs) |
| 201 | + |
| 202 | + |
| 203 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.delete_ccc_upgrade_schedule, |
| 204 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 205 | +@computecloudatcustomer_cli.ccc_upgrade_schedule_group.command( |
| 206 | + name=cli_util.override('delete_ccc_upgrade_schedule.command_name', 'delete'), |
| 207 | + help="""Deletes a Compute Cloud@Customer upgrade schedule by the specified OCID""") |
| 208 | +@cli_util.option('--upgrade-schedule-id', required=True, |
| 209 | + help=u"""Compute Cloud@Customer upgrade schedule OCID.""") |
| 210 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 211 | +@click.pass_context |
| 212 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 213 | +@cli_util.wrap_exceptions |
| 214 | +def delete_ccc_upgrade_schedule(ctx, **kwargs): |
| 215 | + if 'upgrade_schedule_id' in kwargs: |
| 216 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 217 | + kwargs.pop('upgrade_schedule_id') |
| 218 | + ctx.invoke(computecloudatcustomer_cli.delete_ccc_upgrade_schedule, **kwargs) |
| 219 | + |
| 220 | + |
| 221 | +@cli_util.copy_params_from_generated_command(computecloudatcustomer_cli.change_ccc_upgrade_schedule_compartment, |
| 222 | + params_to_exclude=['ccc_upgrade_schedule_id']) |
| 223 | +@computecloudatcustomer_cli.ccc_upgrade_schedule_group.command( |
| 224 | + name=cli_util.override('change_ccc_upgrade_schedule_compartment.command_name', 'change-compartment'), |
| 225 | + help="""Moves a Compute Cloud@Customer upgrade schedule from one compartment to another using the specified OCID.""") |
| 226 | +@cli_util.option('--upgrade-schedule-id', required=True, |
| 227 | + help=u"""Compute Cloud@Customer upgrade schedule OCID.""") |
| 228 | +@json_skeleton_utils.get_cli_json_input_option({}) |
| 229 | +@click.pass_context |
| 230 | +@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}) |
| 231 | +@cli_util.wrap_exceptions |
| 232 | +def change_ccc_upgrade_schedule_compartment(ctx, **kwargs): |
| 233 | + if 'upgrade_schedule_id' in kwargs: |
| 234 | + kwargs['ccc_upgrade_schedule_id'] = kwargs['upgrade_schedule_id'] |
| 235 | + kwargs.pop('upgrade_schedule_id') |
| 236 | + ctx.invoke(computecloudatcustomer_cli.change_ccc_upgrade_schedule_compartment, **kwargs) |
0 commit comments