Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def default_api_version(self):
'role_definitions': '2018-01-01-preview',
'provider_operations_metadata': '2018-01-01-preview'
}),
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2021-06-01-preview', {
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2021-08-01-preview', {
Comment thread
savaradh marked this conversation as resolved.
'agent_pools': '2019-06-01-preview',
'tasks': '2019-06-01-preview',
'task_runs': '2019-06-01-preview',
Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acr/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('sync_window', options_list=['--sync-window', '-w'], help='Required parameter if --sync-schedule is present. Used to determine the schedule duration. Uses ISO 8601 duration format.')
c.argument('sync_schedule', options_list=['--sync-schedule', '-s'], help='Optional parameter to define the sync schedule. Uses cron expression to determine the schedule. If not specified, the instance is considered always online and attempts to sync every minute.', required=False, default="* * * * *")
c.argument('sync_message_ttl', help='Determine how long the sync messages will be kept in the cloud. Uses ISO 8601 duration format.', required=False, default="P2D")
c.argument('notifications', options_list=['--notifications'], nargs='+', help='List of artifact pattern for which notifications need to be generated. Use the format "--notifications [PATTERN1 PATTERN2 ...]".')

with self.argument_context('acr connected-registry update') as c:
c.argument('log_level', help='Set the log level for logging on the instance. Accepted log levels are Debug, Information, Warning, Error, and None.')
Expand All @@ -433,6 +434,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('sync_window', options_list=['--sync-window', '-w'], help='Used to determine the schedule duration. Uses ISO 8601 duration format.')
c.argument('sync_schedule', options_list=['--sync-schedule', '-s'], help='Optional parameter to define the sync schedule. Uses cron expression to determine the schedule. If not specified, the instance is considered always online and attempts to sync every minute.')
c.argument('sync_message_ttl', help='Determine how long the sync messages will be kept in the cloud. Uses ISO 8601 duration format.')
c.argument('add_notifications', options_list=['--add-notifications'], nargs='*',
help='List of artifact pattern to be added to notifications list. Use the format "--add-notifications [PATTERN1 PATTERN2 ...]".')
c.argument('remove_notifications', options_list=['--remove-notifications'], nargs='*',
help='List of artifact pattern to be removed from notifications list. Use the format "--remove-notifications [PATTERN1 PATTERN2 ...]".')

with self.argument_context('acr connected-registry permissions') as c:
c.argument('add_repos', options_list=['--add'], nargs='*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from msrest.exceptions import ValidationError
from knack.log import get_logger
from knack.util import CLIError
from azure.cli.core.azclierror import ArgumentUsageError
from azure.cli.core.commands import LongRunningOperation
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import user_confirmation
Expand Down Expand Up @@ -56,7 +57,8 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
sync_message_ttl=None,
sync_window=None,
log_level=None,
sync_audit_logs_enabled=False):
sync_audit_logs_enabled=False,
notifications=None):

if bool(sync_token_name) == bool(repositories):
raise CLIError("usage error: you must provide either --sync-token-name or --repository, but not both.")
Expand Down Expand Up @@ -104,6 +106,9 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
client_token_list[i] = build_token_id(
subscription_id, resource_group_name, registry_name, client_token_name)

notifications_set = set(list(notifications)) \
if notifications else set()

ConnectedRegistry, LoggingProperties, SyncProperties, ParentProperties = cmd.get_models(
'ConnectedRegistry', 'LoggingProperties', 'SyncProperties', 'ParentProperties')
connected_registry_create_parameters = ConnectedRegistry(
Expand All @@ -122,7 +127,8 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
logging=LoggingProperties(
log_level=log_level,
audit_log_status='Enabled' if sync_audit_logs_enabled else 'Disabled'
)
),
notifications_list=list(notifications_set) if notifications_set else None
)

try:
Expand All @@ -145,7 +151,9 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
sync_window=None,
log_level=None,
sync_message_ttl=None,
sync_audit_logs_enabled=None):
sync_audit_logs_enabled=None,
add_notifications=None,
remove_notifications=None):
_, resource_group_name = validate_managed_registry(
cmd, registry_name, resource_group_name)
subscription_id = get_subscription_id(cmd.cli_ctx)
Expand Down Expand Up @@ -181,11 +189,30 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m

client_token_list = list(client_token_set) if client_token_set != current_client_token_set else None

# Add or remove from the current notifications list
add_notifications_set = set(list(add_notifications)) \
if add_notifications else set()

remove_notifications_set = set(list(remove_notifications)) \
if remove_notifications else set()

duplicate_notifications = set.intersection(add_notifications_set, remove_notifications_set)
if duplicate_notifications:
errors = sorted(duplicate_notifications)
raise ArgumentUsageError(
'Update ambiguity. Duplicate notifications list were provided with ' +
'--add-notifications and --remove-notifications arguments.\n{}'.format(errors))

current_notifications_set = set(current_connected_registry.notifications_list) \
if current_connected_registry.notifications_list else set()
notifications_set = current_notifications_set.union(add_notifications_set).difference(remove_notifications_set)

notifications_list = list(notifications_set) if notifications_set != current_notifications_set else None

ConnectedRegistryUpdateParameters, SyncUpdateProperties, LoggingProperties = cmd.get_models(
'ConnectedRegistryUpdateParameters', 'SyncUpdateProperties', 'LoggingProperties')
connected_registry_update_parameters = ConnectedRegistryUpdateParameters(
sync_properties=SyncUpdateProperties(
token_id=current_connected_registry.parent.sync_properties.token_id,
schedule=sync_schedule,
message_ttl=sync_message_ttl,
sync_window=sync_window
Expand All @@ -194,7 +221,8 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
log_level=log_level,
audit_log_status=sync_audit_logs_enabled
),
client_token_ids=client_token_list
client_token_ids=client_token_list,
notifications_list=notifications_list
)

try:
Expand Down Expand Up @@ -548,12 +576,13 @@ def _update_repo_permissions(cmd,
actions=current_actions
)

return scope_map_client.begin_update(
poller = scope_map_client.begin_update(
resource_group_name,
registry_name,
sync_scope_map_name,
scope_map_update_parameters
)
return LongRunningOperation(cmd.cli_ctx)(poller)


def _get_scope_map_actions_set(repos, actions):
Expand Down
Loading