# coding: utf-8
# Copyright (c) 2016, 2026, Oracle and/or its affiliates.  All rights reserved.
# 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.
# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20180419

from __future__ import print_function
import click
import oci  # noqa: F401
import six  # noqa: F401
import sys  # noqa: F401
from oci_cli.cli_root import cli
from oci_cli import cli_constants  # noqa: F401
from oci_cli import cli_util
from oci_cli import json_skeleton_utils
from oci_cli import custom_types  # noqa: F401
from oci_cli.aliasing import CommandGroupWithAlias


@cli.command(cli_util.override('container_registry.container_registry_root_group.command_name', 'container-registry'), cls=CommandGroupWithAlias, help=cli_util.override('container_registry.container_registry_root_group.help', """OCI Container Registry extension endpoints provide compatibility and extensions for the Docker/Open Container Initiative Distribution Registry HTTP API v2. Use together with the Artifacts and Container Images API for control‑plane repository and image management - https://docs.oracle.com/en-us/iaas/api/#/en/registry/20160918/"""), short_help=cli_util.override('container_registry.container_registry_root_group.short_help', """Container Registry API"""))
@cli_util.help_option_group
def container_registry_root_group():
    pass


@click.command(cli_util.override('container_registry.access_token_group.command_name', 'access-token'), cls=CommandGroupWithAlias, help="""Access token response for OCI Container Registry extension authentication.""")
@cli_util.help_option_group
def access_token_group():
    pass


container_registry_root_group.add_command(access_token_group)


@access_token_group.command(name=cli_util.override('container_registry.get_access_token.command_name', 'get'), help=u"""Get a token using basic auth credentials or signature headers \n[Command Reference](getAccessToken)""")
@cli_util.option('--service', help=u"""Domain name of the target service server.""")
@cli_util.option('--scope', help=u"""Scope to restrict access to resources. Example: `repository:namespace/reponame:pull,push`""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'container_registry', 'class': 'AccessToken'})
@cli_util.wrap_exceptions
def get_access_token(ctx, from_json, service, scope):

    kwargs = {}
    if service is not None:
        kwargs['service'] = service
    if scope is not None:
        kwargs['scope'] = scope
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('container_registry', 'container_registry', ctx)
    result = client.get_access_token(
        **kwargs
    )
    cli_util.render_response(result, ctx)
