forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tanzu component create in service creation
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=too-few-public-methods, unused-argument, redefined-builtin | ||
|
||
from .vendored_sdks.appplatform.v2022_01_01_preview import models | ||
from azure.cli.core.commands.client_factory import get_subscription_id | ||
from msrestazure.tools import resource_id | ||
from knack.log import get_logger | ||
|
||
GATEWAY_RESOURCE_TYPE = "gateways" | ||
DEFAULT_NAME = "default" | ||
logger = get_logger(__name__) | ||
|
||
def create_application_configuration_service(cmd, client, resource_group, service, enable_application_configuration_service=None): | ||
if enable_application_configuration_service: | ||
logger.warning(" - Creating Application Configuration Service ..") | ||
acs_resource = models.ConfigurationServiceResource() | ||
client.configuration_services.begin_create_or_update(resource_group, service, DEFAULT_NAME, acs_resource) | ||
|
||
|
||
def create_service_registry(cmd, client, resource_group, service, enable_service_registry): | ||
if enable_service_registry: | ||
logger.warning(" - Creating Service Registry ..") | ||
client.service_registries.begin_create_or_update(resource_group, service, DEFAULT_NAME) | ||
|
||
|
||
def create_gateway(cmd, client, resource_group, service, enable_gateway): | ||
if enable_gateway: | ||
logger.warning(" - Creating Spring Cloud Gateway ..") | ||
gateway_resource = models.GatewayResource() | ||
client.gateways.begin_create_or_update(resource_group, service, DEFAULT_NAME, gateway_resource) | ||
|
||
|
||
def create_api_portal(cmd, client, resource_group, service, enable_api_portal): | ||
if enable_api_portal: | ||
logger.warning(" - Creating API portal ..") | ||
gateway_id = resource_id( | ||
subscription=get_subscription_id(cmd.cli_ctx), | ||
resource_group=resource_group, | ||
namespace='Microsoft.AppPlatform', | ||
type='Spring', | ||
name=service, | ||
child_type_1=GATEWAY_RESOURCE_TYPE, | ||
child_name_1=DEFAULT_NAME | ||
) | ||
|
||
api_portal_resource = models.GatewayResource( | ||
properties = models.GatewayProperties( | ||
gateway_ids=[gateway_id] | ||
) | ||
) | ||
client.api_portals.begin_create_or_update(resource_group, service, DEFAULT_NAME, api_portal_resource) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters