|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for |
| 5 | +# license information. |
| 6 | +# |
| 7 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
| 10 | +# -------------------------------------------------------------------------- |
| 11 | + |
| 12 | +from msrest.pipeline import ClientRawResponse |
| 13 | +from msrest.exceptions import HttpOperationError |
| 14 | + |
| 15 | +from .. import models |
| 16 | + |
| 17 | + |
| 18 | +class TeamsOperations(object): |
| 19 | + """TeamsOperations operations. |
| 20 | +
|
| 21 | + :param client: Client for service requests. |
| 22 | + :param config: Configuration of service client. |
| 23 | + :param serializer: An object model serializer. |
| 24 | + :param deserializer: An object model deserializer. |
| 25 | + """ |
| 26 | + |
| 27 | + models = models |
| 28 | + |
| 29 | + def __init__(self, client, config, serializer, deserializer): |
| 30 | + |
| 31 | + self._client = client |
| 32 | + self._serialize = serializer |
| 33 | + self._deserialize = deserializer |
| 34 | + |
| 35 | + self.config = config |
| 36 | + |
| 37 | + def fetch_channel_list( |
| 38 | + self, team_id, custom_headers=None, raw=False, **operation_config |
| 39 | + ): |
| 40 | + """Fetches channel list for a given team. |
| 41 | +
|
| 42 | + Fetch the channel list. |
| 43 | +
|
| 44 | + :param team_id: Team Id |
| 45 | + :type team_id: str |
| 46 | + :param dict custom_headers: headers that will be added to the request |
| 47 | + :param bool raw: returns the direct response alongside the |
| 48 | + deserialized response |
| 49 | + :param operation_config: :ref:`Operation configuration |
| 50 | + overrides<msrest:optionsforoperations>`. |
| 51 | + :return: ConversationList or ClientRawResponse if raw=true |
| 52 | + :rtype: ~botframework.connector.teams.models.ConversationList or |
| 53 | + ~msrest.pipeline.ClientRawResponse |
| 54 | + :raises: |
| 55 | + :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` |
| 56 | + """ |
| 57 | + # Construct URL |
| 58 | + url = self.fetch_channel_list.metadata["url"] |
| 59 | + path_format_arguments = { |
| 60 | + "teamId": self._serialize.url("team_id", team_id, "str") |
| 61 | + } |
| 62 | + url = self._client.format_url(url, **path_format_arguments) |
| 63 | + |
| 64 | + # Construct parameters |
| 65 | + query_parameters = {} |
| 66 | + |
| 67 | + # Construct headers |
| 68 | + header_parameters = {} |
| 69 | + header_parameters["Accept"] = "application/json" |
| 70 | + if custom_headers: |
| 71 | + header_parameters.update(custom_headers) |
| 72 | + |
| 73 | + # Construct and send request |
| 74 | + request = self._client.get(url, query_parameters, header_parameters) |
| 75 | + response = self._client.send(request, stream=False, **operation_config) |
| 76 | + |
| 77 | + if response.status_code not in [200]: |
| 78 | + raise HttpOperationError(self._deserialize, response) |
| 79 | + |
| 80 | + deserialized = None |
| 81 | + |
| 82 | + if response.status_code == 200: |
| 83 | + deserialized = self._deserialize("ConversationList", response) |
| 84 | + |
| 85 | + if raw: |
| 86 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 87 | + return client_raw_response |
| 88 | + |
| 89 | + return deserialized |
| 90 | + |
| 91 | + fetch_channel_list.metadata = {"url": "/v3/teams/{teamId}/conversations"} |
| 92 | + |
| 93 | + def fetch_team_details( |
| 94 | + self, team_id, custom_headers=None, raw=False, **operation_config |
| 95 | + ): |
| 96 | + """Fetches details related to a team. |
| 97 | +
|
| 98 | + Fetch details for a team. |
| 99 | +
|
| 100 | + :param team_id: Team Id |
| 101 | + :type team_id: str |
| 102 | + :param dict custom_headers: headers that will be added to the request |
| 103 | + :param bool raw: returns the direct response alongside the |
| 104 | + deserialized response |
| 105 | + :param operation_config: :ref:`Operation configuration |
| 106 | + overrides<msrest:optionsforoperations>`. |
| 107 | + :return: TeamDetails or ClientRawResponse if raw=true |
| 108 | + :rtype: ~botframework.connector.teams.models.TeamDetails or |
| 109 | + ~msrest.pipeline.ClientRawResponse |
| 110 | + :raises: |
| 111 | + :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` |
| 112 | + """ |
| 113 | + # Construct URL |
| 114 | + url = self.fetch_team_details.metadata["url"] |
| 115 | + path_format_arguments = { |
| 116 | + "teamId": self._serialize.url("team_id", team_id, "str") |
| 117 | + } |
| 118 | + url = self._client.format_url(url, **path_format_arguments) |
| 119 | + |
| 120 | + # Construct parameters |
| 121 | + query_parameters = {} |
| 122 | + |
| 123 | + # Construct headers |
| 124 | + header_parameters = {} |
| 125 | + header_parameters["Accept"] = "application/json" |
| 126 | + if custom_headers: |
| 127 | + header_parameters.update(custom_headers) |
| 128 | + |
| 129 | + # Construct and send request |
| 130 | + request = self._client.get(url, query_parameters, header_parameters) |
| 131 | + response = self._client.send(request, stream=False, **operation_config) |
| 132 | + |
| 133 | + if response.status_code not in [200]: |
| 134 | + raise HttpOperationError(self._deserialize, response) |
| 135 | + |
| 136 | + deserialized = None |
| 137 | + |
| 138 | + if response.status_code == 200: |
| 139 | + deserialized = self._deserialize("TeamDetails", response) |
| 140 | + |
| 141 | + if raw: |
| 142 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 143 | + return client_raw_response |
| 144 | + |
| 145 | + return deserialized |
| 146 | + |
| 147 | + fetch_team_details.metadata = {"url": "/v3/teams/{teamId}"} |
0 commit comments