-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1edec21
add support for oauth to botservice cli
2ab280d
minor fixes
b9fa047
fix style warnings
36f4c2a
more pylint error fixes
05cde9b
fix flake errors
a6c391b
addressed comments. bumped up version
5072e48
Merge branch 'master' into master
williexu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,30 @@ | |
type: command | ||
short-summary: Create Slack Channel on a Bot. | ||
""" | ||
helps['bot connection'] = """ | ||
type: command | ||
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'] = """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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:] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
c.argument('name', options_list=['--provider-name'], help='service provider name for which to fetch details') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
__all__ = ['AzureBotService'] | ||
|
||
__version__ = VERSION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/botservice/azext_bot/botservice/models/connection_item_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
63
src/botservice/azext_bot/botservice/models/connection_setting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
27 changes: 27 additions & 0 deletions
27
src/botservice/azext_bot/botservice/models/connection_setting_paged.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
32 changes: 32 additions & 0 deletions
32
src/botservice/azext_bot/botservice/models/connection_setting_parameter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
63 changes: 63 additions & 0 deletions
63
src/botservice/azext_bot/botservice/models/connection_setting_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
src/botservice/azext_bot/botservice/models/service_provider.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type: group