Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/confluent/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Release History
===============

0.2.0
+++++
* [BREAKING CHANGE] `az confluent organization create`: Remove `--user-detail`, the parameter is now auto-filled by the email address, first name and last name decoded from access token.
* [BREAKING CHANGE] `az confluent organization create`: Flatten `--offer-detail` to `--offer-id`, `--plan-id`, `--plan-name`, `--publisher-id` and `--term-unit`.
* Add new command `az confluent offer-detail show`.
* `az confluent organization create`: Add Owner or Contributor access check of the subscription before creating the organization.
* `az confluent organization delete`: Customize confirmation message based on plan type.

0.1.0
++++++
* Initial release.
3 changes: 2 additions & 1 deletion src/confluent/azext_confluent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=import-outside-toplevel

from azure.cli.core import AzCommandsLoader
from azext_confluent.generated._help import helps # pylint: disable=unused-import
Expand All @@ -24,7 +25,7 @@ def __init__(self, cli_ctx=None):
confluent_custom = CliCommandType(
operations_tmpl='azext_confluent.custom#{}',
client_factory=cf_confluent_cl)
parent = super(ConfluentManagementClientCommandsLoader, self)
parent = super()
parent.__init__(cli_ctx=cli_ctx, custom_command_type=confluent_custom)

def load_command_table(self, args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=import-outside-toplevel


def cf_confluent_cl(cli_ctx, *_):
Expand All @@ -17,7 +18,7 @@ def cf_confluent_cl(cli_ctx, *_):


def cf_marketplace_agreement(cli_ctx, *_):
return cf_confluent_cl(cli_ctx).marketplace_agreement
return cf_confluent_cl(cli_ctx).marketplace_agreements


def cf_organization(cli_ctx, *_):
Expand Down
26 changes: 2 additions & 24 deletions src/confluent/azext_confluent/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,11 @@
helps['confluent organization create'] = """
type: command
short-summary: "Create Organization resource."
parameters:
- name: --offer-detail
short-summary: "Confluent offer detail"
long-summary: |
Usage: --offer-detail publisher-id=XX id=XX plan-id=XX plan-name=XX term-unit=XX status=XX

publisher-id: Publisher Id
id: Offer Id
plan-id: Offer Plan Id
plan-name: Offer Plan Name
term-unit: Offer Plan Term unit
status: SaaS Offer Status
- name: --user-detail
short-summary: "Subscriber detail"
long-summary: |
Usage: --user-detail first-name=XX last-name=XX email-address=XX

first-name: First name
last-name: Last name
email-address: Email address
examples:
- name: Organization_Create
text: |-
az confluent organization create --location "West US" --offer-detail id="string" plan-id="string" \
plan-name="string" publisher-id="string" term-unit="string" --user-detail email-address="[email protected]" \
first-name="string" last-name="string" --tags Environment="Dev" --name "myOrganization" --resource-group \
"myResourceGroup"
az confluent organization create --location "West US" --tags Environment="Dev" --name "myOrganization" \
--resource-group "myResourceGroup"
"""

helps['confluent organization update'] = """
Expand Down
11 changes: 5 additions & 6 deletions src/confluent/azext_confluent/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
get_location_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from azext_confluent.action import (
AddOfferDetail,
AddUserDetail
)


def load_arguments(self, _):
Expand All @@ -39,8 +35,11 @@ def load_arguments(self, _):
c.argument('tags', tags_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('offer_detail', action=AddOfferDetail, nargs='+', help='Confluent offer detail')
c.argument('user_detail', action=AddUserDetail, nargs='+', help='Subscriber detail')
c.argument('publisher_id', type=str, help='Publisher Id')
c.argument('offer_id', type=str, help='Offer Id')
c.argument('plan_id', type=str, help='Offer Plan Id')
c.argument('plan_name', type=str, help='Offer Plan Name')
c.argument('term_unit', type=str, help='Offer Plan Term unit')

with self.argument_context('confluent organization update') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand Down
62 changes: 0 additions & 62 deletions src/confluent/azext_confluent/generated/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,3 @@
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=protected-access

import argparse
from collections import defaultdict
from knack.util import CLIError


class AddOfferDetail(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.offer_detail = action

def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
properties[k].append(v)
properties = dict(properties)
except ValueError:
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:
kl = k.lower()
v = properties[k]
if kl == 'publisher-id':
d['publisher_id'] = v[0]
elif kl == 'id':
d['id'] = v[0]
elif kl == 'plan-id':
d['plan_id'] = v[0]
elif kl == 'plan-name':
d['plan_name'] = v[0]
elif kl == 'term-unit':
d['term_unit'] = v[0]
elif kl == 'status':
d['status'] = v[0]
return d


class AddUserDetail(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.user_detail = action

def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
properties[k].append(v)
properties = dict(properties)
except ValueError:
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:
kl = k.lower()
v = properties[k]
if kl == 'first-name':
d['first_name'] = v[0]
elif kl == 'last-name':
d['last_name'] = v[0]
elif kl == 'email-address':
d['email_address'] = v[0]
return d
13 changes: 8 additions & 5 deletions src/confluent/azext_confluent/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# --------------------------------------------------------------------------
# pylint: disable=too-many-statements
# pylint: disable=too-many-locals
# pylint: disable=import-outside-toplevel

from azure.cli.core.commands import CliCommandType

Expand All @@ -17,23 +18,25 @@ def load_command_table(self, _):

from azext_confluent.generated._client_factory import cf_marketplace_agreement
confluent_marketplace_agreement = CliCommandType(
operations_tmpl='azext_confluent.vendored_sdks.confluent.operations._marketplace_agreement_operations#Marketpla'
'ceAgreementOperations.{}',
operations_tmpl='azext_confluent.vendored_sdks.confluent.operations._marketplace_agreements_operations#Marketpl'
'aceAgreementsOperations.{}',
client_factory=cf_marketplace_agreement)
with self.command_group('confluent terms', confluent_marketplace_agreement,
client_factory=cf_marketplace_agreement, is_experimental=True) as g:
client_factory=cf_marketplace_agreement) as g:
g.custom_command('list', 'confluent_terms_list')

from azext_confluent.generated._client_factory import cf_organization
confluent_organization = CliCommandType(
operations_tmpl='azext_confluent.vendored_sdks.confluent.operations._organization_operations#OrganizationOperat'
'ions.{}',
client_factory=cf_organization)
with self.command_group('confluent organization', confluent_organization, client_factory=cf_organization,
is_experimental=True) as g:
with self.command_group('confluent organization', confluent_organization, client_factory=cf_organization) as g:
g.custom_command('list', 'confluent_organization_list')
g.custom_show_command('show', 'confluent_organization_show')
g.custom_command('create', 'confluent_organization_create', supports_no_wait=True)
g.custom_command('update', 'confluent_organization_update')
g.custom_command('delete', 'confluent_organization_delete', supports_no_wait=True, confirmation=True)
g.custom_wait_command('wait', 'confluent_organization_show')

with self.command_group('confluent', is_experimental=True):
pass
26 changes: 18 additions & 8 deletions src/confluent/azext_confluent/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,37 @@ def confluent_organization_create(client,
organization_name,
tags=None,
location=None,
offer_detail=None,
user_detail=None,
publisher_id=None,
offer_id=None,
plan_id=None,
plan_name=None,
term_unit=None,
no_wait=False):
body = {}
body['tags'] = tags
body['location'] = location
body['offer_detail'] = {}
body['offer_detail']['publisher_id'] = publisher_id
body['offer_detail']['id'] = offer_id
body['offer_detail']['plan_id'] = plan_id
body['offer_detail']['plan_name'] = plan_name
body['offer_detail']['term_unit'] = term_unit
return sdk_no_wait(no_wait,
client.begin_create,
resource_group_name=resource_group_name,
organization_name=organization_name,
tags=tags,
location=location,
provisioning_state=None,
offer_detail=offer_detail,
user_detail=user_detail)
body=body)


def confluent_organization_update(client,
resource_group_name,
organization_name,
tags=None):
body = {}
body['tags'] = tags
return client.update(resource_group_name=resource_group_name,
organization_name=organization_name,
tags=tags)
body=body)


def confluent_organization_delete(client,
Expand Down
25 changes: 25 additions & 0 deletions src/confluent/azext_confluent/manual/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
short-summary: Manage confluent resources
"""

helps['confluent organization create'] = """
type: command
short-summary: "Create Organization resource."
examples:
- name: Create organization
text: |-
az confluent organization create --location "West US" --tags Environment="Dev" --name "myOrganization" \
--resource-group "myResourceGroup" --offer-id "confluent-cloud-azure-prod" --plan-id "confluent-cloud-azure-payg-prod" \
--plan-name "Confluent Cloud - Pay as you Go" --publisher-id "confluentinc" --term-unit "P1M"
"""

helps['confluent organization show'] = """
type: command
short-summary: "Get the properties of a specific Organization resource."
Expand All @@ -39,3 +50,17 @@
text: |-
az confluent organization delete --ids "/subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Confluent/organizations/{myOrganization}"
"""

helps['confluent offer-detail'] = """
type: group
short-summary: Manage confluent offer details
"""

helps['confluent offer-detail show'] = """
type: command
short-summary: "Get the offer details for available offers."
examples:
- name: Show default offer details
text: |-
az confluent offer-detail show
"""
27 changes: 27 additions & 0 deletions src/confluent/azext_confluent/manual/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def load_arguments(self, _):
with self.argument_context('confluent organization create') as c:
c.argument('publisher_id', type=str, help='Publisher Id', default='confluentinc', arg_group='Offer Detail')
c.argument('offer_id', type=str, help='Offer Id', default='confluent-cloud-azure-prod',
arg_group='Offer Detail')
c.argument('plan_id', type=str, help='Offer Plan Id', arg_group='Offer Detail')
c.argument('plan_name', type=str, help='Offer Plan Name', arg_group='Offer Detail')
c.argument('term_unit', type=str, help='Offer Plan Term unit', arg_group='Offer Detail')

with self.argument_context('confluent organization delete') as c:
c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.')

with self.argument_context('confluent offer-detail show') as c:
c.argument('publisher_id', type=str, help='Publisher Id', default='confluentinc')
c.argument('offer_id', type=str, help='Offer Id', default='confluent-cloud-azure-prod',
arg_group='Offer Detail')
27 changes: 27 additions & 0 deletions src/confluent/azext_confluent/manual/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=import-outside-toplevel

from azure.cli.core.commands import CliCommandType


def load_command_table(self, _):

from azext_confluent.generated._client_factory import cf_organization

confluent_organization = CliCommandType(
operations_tmpl='azext_confluent.vendored_sdks.confluent.operations._organization_operations#OrganizationOperat'
'ions.{}',
client_factory=cf_organization)
with self.command_group('confluent organization', confluent_organization, client_factory=cf_organization) as g:
g.custom_command('delete', 'confluent_organization_delete', supports_no_wait=True)

with self.command_group('confluent offer-detail') as g:
g.custom_show_command('show', 'confluent_offer_detail_show')
Loading