Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for oauth connection management in botservice #213

Merged
merged 7 commits into from
Jun 26, 2018
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
586 changes: 586 additions & 0 deletions src/botservice/azext_bot/.vscode/tags

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions src/botservice/azext_bot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@
type: command
short-summary: Create Slack Channel on a Bot.
"""
helps['bot connection'] = """
type: command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: group

short-summary: Manage OAuth Connection Settings on a Bot.
"""
helps['bot connection create'] = """
type: command
short-summary: Create an OAuth Connection Setting on a Bot.
"""
helps['bot connection show'] = """
type: command
short-summary: Show details of an OAuth Connection Setting on a Bot.
"""
helps['bot connection list'] = """
type: command
short-summary: Show all OAuth Connection Settings on a Bot.
"""
helps['bot connection delete'] = """
type: command
short-summary: Delete an OAuth Connection Setting on a Bot.
"""
helps['bot connection listproviders'] = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list-providers

type: command
short-summary: List Details of All service Providers available for creating OAuth Connection Settings.
"""

for channel in ['facebook', 'email', 'msteams', 'skype', 'kik', 'webchat', 'directline', 'telegram', 'sms', 'slack']:
channelTitle = channel[:1].upper() + channel[1:]
Expand Down
14 changes: 14 additions & 0 deletions src/botservice/azext_bot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,17 @@ def load_arguments(self, _):
c.argument('client_id', help='The client id from slack')
c.argument('verification_token', help='The verification token from slack')
c.argument('landing_page_url', help='The landing page url to redirect to after login')

with self.argument_context('bot connection') as c:
c.argument('connection_name', options_list=['--connection-name', '-c'], help='name of the oauth connection setting')

with self.argument_context('bot connection create') as c:
c.argument('client_id', help='client id associated with the service provider setting')
c.argument('client_secret', help='client secret associated with the service provider setting')
c.argument('scopes', help='scopes associated with the service provider setting.The format depends on the service provider.')
c.argument('service_provider_name', options_list=['--service'], help='name of the service provider. For a list of all service providers, use az bot connection listserviceproviders')
c.argument('parameters', help='parameter values for Service Provider Parameters. Usage: --parameters key=value key1=value1', nargs='+')

with self.argument_context('bot connection listproviders') as c:
c.argument('as_raw_settings', options_list=['--asraw'], help='Output the raw json for each service provider', arg_type=get_three_state_flag())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options_list=['--as-raw']

c.argument('name', options_list=['--provider-name'], help='service provider name for which to fetch details')
1 change: 1 addition & 0 deletions src/botservice/azext_bot/botservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
__all__ = ['AzureBotService']

__version__ = VERSION

5 changes: 5 additions & 0 deletions src/botservice/azext_bot/botservice/azure_bot_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .operations.bots_operations import BotsOperations
from .operations.channels_operations import ChannelsOperations
from .operations.operations import Operations
from .operations.bot_connection_operations import BotConnectionOperations
from . import models


Expand Down Expand Up @@ -63,6 +64,8 @@ class AzureBotService(object):
:vartype channels: azure.mgmt.botservice.operations.ChannelsOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.botservice.operations.Operations
:ivar bot_connection: BotConnection operations
:vartype bot_connection: azure.mgmt.botservice.operations.BotConnectionOperations

:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
Expand All @@ -89,3 +92,5 @@ def __init__(
self._client, self.config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
self.bot_connection = BotConnectionOperations(
self._client, self.config, self._serialize, self._deserialize)
18 changes: 18 additions & 0 deletions src/botservice/azext_bot/botservice/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
from .sms_channel import SmsChannel
from .slack_channel_properties import SlackChannelProperties
from .slack_channel import SlackChannel
from .connection_item_name import ConnectionItemName
from .connection_setting_parameter import ConnectionSettingParameter
from .connection_setting_properties import ConnectionSettingProperties
from .connection_setting import ConnectionSetting
from .service_provider_parameter import ServiceProviderParameter
from .service_provider_properties import ServiceProviderProperties
from .service_provider import ServiceProvider
from .service_provider_response_list import ServiceProviderResponseList
from .error_body import ErrorBody
from .error import Error, ErrorException
from .operation_display_info import OperationDisplayInfo
Expand All @@ -47,6 +55,7 @@
from .bot_paged import BotPaged
from .bot_channel_paged import BotChannelPaged
from .operation_entity_paged import OperationEntityPaged
from .connection_setting_paged import ConnectionSettingPaged
from .azure_bot_service_enums import (
SkuName,
SkuTier,
Expand Down Expand Up @@ -84,6 +93,14 @@
'SmsChannel',
'SlackChannelProperties',
'SlackChannel',
'ConnectionItemName',
'ConnectionSettingParameter',
'ConnectionSettingProperties',
'ConnectionSetting',
'ServiceProviderParameter',
'ServiceProviderProperties',
'ServiceProvider',
'ServiceProviderResponseList',
'ErrorBody',
'Error', 'ErrorException',
'OperationDisplayInfo',
Expand All @@ -93,6 +110,7 @@
'BotPaged',
'BotChannelPaged',
'OperationEntityPaged',
'ConnectionSettingPaged',
'SkuName',
'SkuTier',
'Kind',
Expand Down
34 changes: 34 additions & 0 deletions src/botservice/azext_bot/botservice/models/connection_item_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class ConnectionItemName(Model):
"""The display name of a connection Item Setting registered with the Bot.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar name: Connection Item name that has been added in the API
:vartype name: str
"""

_validation = {
'name': {'readonly': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
}

def __init__(self):
self.name = None
63 changes: 63 additions & 0 deletions src/botservice/azext_bot/botservice/models/connection_setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from .resource import Resource


class ConnectionSetting(Resource):
"""Bot channel resource definition.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar id: Specifies the resource ID.
:vartype id: str
:ivar name: Specifies the name of the resource.
:vartype name: str
:param location: Specifies the location of the resource.
:type location: str
:ivar type: Specifies the type of the resource.
:vartype type: str
:param tags: Contains resource tags defined as key/value pairs.
:type tags: dict[str, str]
:param sku: Gets or sets the SKU of the resource.
:type sku: ~azure.mgmt.botservice.models.Sku
:param kind: Required. Gets or sets the Kind of the resource. Possible
values include: 'sdk', 'designer', 'bot', 'function'
:type kind: str or ~azure.mgmt.botservice.models.Kind
:param etag: Entity Tag
:type etag: str
:param properties: The set of properties specific to bot channel resource
:type properties:
~azure.mgmt.botservice.models.ConnectionSettingProperties
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
}

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'sku': {'key': 'sku', 'type': 'Sku'},
'kind': {'key': 'kind', 'type': 'str'},
'etag': {'key': 'etag', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'ConnectionSettingProperties'},
}

def __init__(self, location=None, tags=None, sku=None, kind=None, etag=None, properties=None):
super(ConnectionSetting, self).__init__(location=location, tags=tags, sku=sku, kind=kind, etag=etag)
self.properties = properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from msrest.paging import Paged


class ConnectionSettingPaged(Paged):
"""
A paging container for iterating over a list of :class:`ConnectionSetting <azure.mgmt.botservice.models.ConnectionSetting>` object
"""

_attribute_map = {
'next_link': {'key': 'nextLink', 'type': 'str'},
'current_page': {'key': 'value', 'type': '[ConnectionSetting]'}
}

def __init__(self, *args, **kwargs):

super(ConnectionSettingPaged, self).__init__(*args, **kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class ConnectionSettingParameter(Model):
"""Extra Parameter in a Connection Setting Properties to indicate service
provider specific properties.

:param key: Key for the Connection Setting Parameter.
:type key: str
:param value: Value associated with the Connection Setting Parameter.
:type value: str
"""

_attribute_map = {
'key': {'key': 'key', 'type': 'str'},
'value': {'key': 'value', 'type': 'str'},
}

def __init__(self, key=None, value=None):
self.key = key
self.value = value
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class ConnectionSettingProperties(Model):
"""Properties for a Connection Setting Item.

Variables are only populated by the server, and will be ignored when
sending a request.

:param client_id: Client Id associated with the Connection Setting.
:type client_id: str
:ivar setting_id: Setting Id set by the service for the Connection
Setting.
:vartype setting_id: str
:param client_secret: Client Secret associated with the Connection Setting
:type client_secret: str
:param scopes: Scopes associated with the Connection Setting
:type scopes: str
:param service_provider_id: Service Provider Id associated with the
Connection Setting
:type service_provider_id: str
:param service_provider_display_name: Service Provider Display Name
associated with the Connection Setting
:type service_provider_display_name: str
:param parameters: Service Provider Parameters associated with the
Connection Setting
:type parameters:
list[~azure.mgmt.botservice.models.ConnectionSettingParameter]
"""

_validation = {
'setting_id': {'readonly': True},
}

_attribute_map = {
'client_id': {'key': 'clientId', 'type': 'str'},
'setting_id': {'key': 'settingId', 'type': 'str'},
'client_secret': {'key': 'clientSecret', 'type': 'str'},
'scopes': {'key': 'scopes', 'type': 'str'},
'service_provider_id': {'key': 'serviceProviderId', 'type': 'str'},
'service_provider_display_name': {'key': 'serviceProviderDisplayName', 'type': 'str'},
'parameters': {'key': 'parameters', 'type': '[ConnectionSettingParameter]'},
}

def __init__(self, client_id=None, client_secret=None, scopes=None, service_provider_id=None, service_provider_display_name=None, parameters=None):
self.client_id = client_id
self.setting_id = None
self.client_secret = client_secret
self.scopes = scopes
self.service_provider_id = service_provider_id
self.service_provider_display_name = service_provider_display_name
self.parameters = parameters
27 changes: 27 additions & 0 deletions src/botservice/azext_bot/botservice/models/service_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class ServiceProvider(Model):
"""Service Provider Definition.

:param properties: The Properties of a Service Provider Object
:type properties: ~azure.mgmt.botservice.models.ServiceProviderProperties
"""

_attribute_map = {
'properties': {'key': 'properties', 'type': 'ServiceProviderProperties'},
}

def __init__(self, properties=None):
self.properties = properties
Loading