Class: Verizon::ServiceProfilesController

Inherits:
BaseController show all
Defined in:
lib/verizon/controllers/service_profiles_controller.rb

Overview

ServiceProfilesController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from Verizon::BaseController

Instance Method Details

#create_service_profile(body) ⇒ ApiResponse

Creates a service profile that describes the resource requirements of a service. passes all of the needed parameters to create a service profile. Parameters will be edited here rather than the Parameters section above. The ‘maxLatencyMs` and `clientType` parameters are both required in the request body. Note: The `maxLatencyMs` value must be submitted in multiples of 5. Additionally, “GPU” is future functionality and the values are not captured.

Parameters:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/verizon/controllers/service_profiles_controller.rb', line 19

def create_service_profile(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/serviceprofiles',
                                 Server::EDGE_DISCOVERY)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CreateServiceProfileResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'HTTP 400 Bad Request.',
                             EdgeDiscoveryResultException)
                .local_error('401',
                             'HTTP 401 Unauthorized.',
                             EdgeDiscoveryResultException)
                .local_error('default',
                             'HTTP 500 Internal Server Error.',
                             EdgeDiscoveryResultException))
    .execute
end

#delete_service_profile(service_profile_id) ⇒ ApiResponse

Delete Service Profile based on unique service profile ID.

Parameters:

  • service_profile_id (String)

    Required parameter: Example:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/verizon/controllers/service_profiles_controller.rb', line 139

def delete_service_profile(service_profile_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/serviceprofiles/{serviceProfileId}',
                                 Server::EDGE_DISCOVERY)
               .template_param(new_parameter(service_profile_id, key: 'serviceProfileId')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DeleteServiceProfileResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'HTTP 400 Bad Request.',
                             EdgeDiscoveryResultException)
                .local_error('401',
                             'HTTP 401 Unauthorized.',
                             EdgeDiscoveryResultException)
                .local_error('default',
                             'HTTP 500 Internal Server Error.',
                             EdgeDiscoveryResultException))
    .execute
end

#get_service_profile(service_profile_id) ⇒ ApiResponse

Returns a specified service profile.

Parameters:

  • service_profile_id (String)

    Required parameter: Example:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/verizon/controllers/service_profiles_controller.rb', line 73

def get_service_profile(service_profile_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/serviceprofiles/{serviceProfileId}',
                                 Server::EDGE_DISCOVERY)
               .template_param(new_parameter(service_profile_id, key: 'serviceProfileId')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ResourcesServiceProfileWithId.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'HTTP 400 Bad Request.',
                             EdgeDiscoveryResultException)
                .local_error('401',
                             'HTTP 401 Unauthorized.',
                             EdgeDiscoveryResultException)
                .local_error('default',
                             'HTTP 500 Internal Server Error.',
                             EdgeDiscoveryResultException))
    .execute
end

#list_service_profilesApiResponse

List all service profiles registered under your API key.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/verizon/controllers/service_profiles_controller.rb', line 47

def list_service_profiles
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/serviceprofiles',
                                 Server::EDGE_DISCOVERY)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListServiceProfilesResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'HTTP 400 Bad Request.',
                             EdgeDiscoveryResultException)
                .local_error('401',
                             'HTTP 401 Unauthorized.',
                             EdgeDiscoveryResultException)
                .local_error('default',
                             'HTTP 500 Internal Server Error.',
                             EdgeDiscoveryResultException))
    .execute
end

#update_service_profile(service_profile_id, body) ⇒ ApiResponse

Update the definition of a Service Profile. passes the rest of the needed parameters to create a service profile. The ‘maxLatencyMs` and `clientType` parameters are both required in the request body. Note: The `maxLatencyMs` value must be submitted in multiples of 5. Additionally, “GPU” is future functionality and the values are not captured. Default values to use are shown.

Parameters:

  • service_profile_id (String)

    Required parameter: Example:

  • body (ResourcesServiceProfile)

    Required parameter: The request body

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/verizon/controllers/service_profiles_controller.rb', line 107

def update_service_profile(service_profile_id,
                           body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/serviceprofiles/{serviceProfileId}',
                                 Server::EDGE_DISCOVERY)
               .template_param(new_parameter(service_profile_id, key: 'serviceProfileId')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(UpdateServiceProfileResult.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'HTTP 400 Bad Request.',
                             EdgeDiscoveryResultException)
                .local_error('401',
                             'HTTP 401 Unauthorized.',
                             EdgeDiscoveryResultException)
                .local_error('default',
                             'HTTP 500 Internal Server Error.',
                             EdgeDiscoveryResultException))
    .execute
end