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
12import uuid
13from msrest.pipeline import ClientRawResponse
14
15from .. import models
16
17
18class Operations(object):
19    """Operations 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    :ivar api_version: Client API version. Constant value: "2017-04-01".
26    """
27
28    models = models
29
30    def __init__(self, client, config, serializer, deserializer):
31
32        self._client = client
33        self._serialize = serializer
34        self._deserialize = deserializer
35        self.api_version = "2017-04-01"
36
37        self.config = config
38
39    def list(
40            self, custom_headers=None, raw=False, **operation_config):
41        """Lists all available Relay REST API operations.
42
43        :param dict custom_headers: headers that will be added to the request
44        :param bool raw: returns the direct response alongside the
45         deserialized response
46        :param operation_config: :ref:`Operation configuration
47         overrides<msrest:optionsforoperations>`.
48        :return: An iterator like instance of Operation
49        :rtype:
50         ~azure.mgmt.relay.models.OperationPaged[~azure.mgmt.relay.models.Operation]
51        :raises:
52         :class:`ErrorResponseException<azure.mgmt.relay.models.ErrorResponseException>`
53        """
54        def internal_paging(next_link=None, raw=False):
55
56            if not next_link:
57                # Construct URL
58                url = self.list.metadata['url']
59
60                # Construct parameters
61                query_parameters = {}
62                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
63
64            else:
65                url = next_link
66                query_parameters = {}
67
68            # Construct headers
69            header_parameters = {}
70            header_parameters['Accept'] = 'application/json'
71            if self.config.generate_client_request_id:
72                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
73            if custom_headers:
74                header_parameters.update(custom_headers)
75            if self.config.accept_language is not None:
76                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
77
78            # Construct and send request
79            request = self._client.get(url, query_parameters, header_parameters)
80            response = self._client.send(request, stream=False, **operation_config)
81
82            if response.status_code not in [200]:
83                raise models.ErrorResponseException(self._deserialize, response)
84
85            return response
86
87        # Deserialize response
88        deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies)
89
90        if raw:
91            header_dict = {}
92            client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict)
93            return client_raw_response
94
95        return deserialized
96    list.metadata = {'url': '/providers/Microsoft.Relay/operations'}
97