huskar_api/api/infra_config.py
def put(self, application_name, infra_type, infra_name):
        """Configures the infrastructure in specified application.

        The input schema looks like::

            {
              "url": "sam+redis://redis.foobar/overall"
            }

        :param application_name: The application which uses infrastructure.
        :param infra_type: ``database``, ``redis`` or ``amqp``.
        :param infra_name: The unique code-reference name of infrastructure.
        :query scope_type: ``idcs`` or ``clusters``.
        :query scope_name: The ezone id or cluster name.
        :query owner_mail: The email of resource owner which will receive the
                           notification of infra config creation.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: ``application/json``
        :status 200: The same as ``GET``.
        """
        with self._update(
                application_name, request, infra_type, infra_name) as args:
            application_name, infra_info, scope_type, scope_name, value = args
            owner_mail = request.args.get('owner_mail', '').strip()
            is_newcomer = len(infra_info.list_by_infra_name(infra_name)) == 0
            infra_info.set_by_name(infra_name, scope_type, scope_name, value)

        if is_newcomer and owner_mail:
            owned_application = Application.get_by_name(application_name)
            owner_user = User.get_by_email(owner_mail)
            infra_owner_emails = settings.ADMIN_INFRA_OWNER_EMAILS.get(
                infra_type, [])
            is_authorized = (
                owner_user is not None and
                owned_application.check_auth(Authority.READ, owner_user.id)
            )
            deliver_email_safe(EmailTemplate.INFRA_CONFIG_CREATE, owner_mail, {
                'application_name': application_name,
                'infra_name': infra_name,
                'infra_type': infra_type,
                'is_authorized': is_authorized,
            }, cc=infra_owner_emails)
        infra_config = infra_info.list_by_infra_name(infra_name)
        return api_response({'infra_config': dump_infra_config(infra_config)})
Configures the infrastructure in specified application.

        The input schema looks like::

            {
              "url": "sam+redis://redis.foobar/overall"
            }

        :param application_name: The application which uses infrastructure.
        :param infra_type: ``database``, ``redis`` or ``amqp``.
        :param infra_name: The unique code-reference name of infrastructure.
        :query scope_type: ``idcs`` or ``clusters``.
        :query scope_name: The ezone id or cluster name.
        :query owner_mail: The email of resource owner which will receive the
                           notification of infra config creation.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: ``application/json``
        :status 200: The same as ``GET``.
        
Configures the infrastructure in specified application.
The input schema looks like:.


Configures the infrastructure in specified application . The input schema looks like : .
def put(self, application_name, infra_type, infra_name):
        with self._update(
                application_name, request, infra_type, infra_name) as args:
            application_name, infra_info, scope_type, scope_name, value = args
            owner_mail = request.args.get('owner_mail', '').strip()
            is_newcomer = len(infra_info.list_by_infra_name(infra_name)) == 0
            infra_info.set_by_name(infra_name, scope_type, scope_name, value)
        if is_newcomer and owner_mail:
            owned_application = Application.get_by_name(application_name)
            owner_user = User.get_by_email(owner_mail)
            infra_owner_emails = settings.ADMIN_INFRA_OWNER_EMAILS.get(
                infra_type, [])
            is_authorized = (
                owner_user is not None and
                owned_application.check_auth(Authority.READ, owner_user.id)
            )
            deliver_email_safe(EmailTemplate.INFRA_CONFIG_CREATE, owner_mail, {
                'application_name': application_name,
                'infra_name': infra_name,
                'infra_type': infra_type,
                'is_authorized': is_authorized,
            }, cc=infra_owner_emails)
        infra_config = infra_info.list_by_infra_name(infra_name)
        return api_response({'infra_config': dump_infra_config(infra_config)})
def put ( self , application_name , infra_type , infra_name ) : with self . _update ( application_name , request , infra_type , infra_name ) as args : application_name , infra_info , scope_type , scope_name , value = args owner_mail = request . args . get ( 'owner_mail' , '' ) . strip ( ) is_newcomer = len ( infra_info . list_by_infra_name ( infra_name ) ) == 0 infra_info . set_by_name ( infra_name , scope_type , scope_name , value ) if is_newcomer and owner_mail : owned_application = Application . get_by_name ( application_name ) owner_user = User . get_by_email ( owner_mail ) infra_owner_emails = settings . ADMIN_INFRA_OWNER_EMAILS . get ( infra_type , [ ] ) is_authorized = ( owner_user is not None and owned_application . check_auth ( Authority . READ , owner_user . id ) ) deliver_email_safe ( EmailTemplate . INFRA_CONFIG_CREATE , owner_mail , { 'application_name' : application_name , 'infra_name' : infra_name , 'infra_type' : infra_type , 'is_authorized' : is_authorized , } , cc = infra_owner_emails ) infra_config = infra_info . list_by_infra_name ( infra_name ) return api_response ( { 'infra_config' : dump_infra_config ( infra_config ) } )
Configures the infrastructure in specified application.
Configures the infrastructure in specified application .
"""Configures the infrastructure in specified application.

        The input schema looks like::

            {
              "url": "sam+redis://redis.foobar/overall"
            }

        :param application_name: The application which uses infrastructure.
        :param infra_type: ``database``, ``redis`` or ``amqp``.
        :param infra_name: The unique code-reference name of infrastructure.
        :query scope_type: ``idcs`` or ``clusters``.
        :query scope_name: The ezone id or cluster name.
        :query owner_mail: The email of resource owner which will receive the
                           notification of infra config creation.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: ``application/json``
        :status 200: The same as ``GET``.
        """
self
application_name
The application which uses infrastructure.
The application which uses infrastructure .
infra_type
None
infra_name
The unique code-reference name of infrastructure.
The unique code - reference name of infrastructure .
query
None
query
The ezone id or cluster name.
The ezone id or cluster name .
query
The email of resource owner which will receive the
notification of infra config creation.
The email of resource owner which will receive the notification of infra config creation .
<header
Huskar Token (See :ref:`token`)
Huskar Token ( See : ref : ` token ` )
<header
None
status
The same as ``GET``.
The same as ` ` GET ` ` .